DeepSeek-V3/app.py
Hitesh Yadav 7d95c3e5ec Improve accessibility for CAPTCHA challenges in DeepSeek v3
Add accessible CAPTCHA solution using hCaptcha to improve accessibility for visually impaired users.

* **Add dependencies**: Add `hcaptcha` and `flask` to `requirements.txt`.
* **Implement hCaptcha in Flask app**: Create `app.py` to set up Flask application, configure hCaptcha, and create routes for sign-up and login with hCaptcha integration.
* **Create sign-up form**: Add `templates/signup.html` with HTML form for user sign-up, integrating hCaptcha widget and adding ARIA labels and roles for screen reader compatibility.
* **Create login form**: Add `templates/login.html` with HTML form for user login, integrating hCaptcha widget and adding ARIA labels and roles for screen reader compatibility.
* **Add CSS styles**: Add `static/css/styles.css` to style form elements and hCaptcha widget, ensuring high contrast and readability for visually impaired users.
* **Write unit tests**: Add `tests/test_accessibility.py` to test accessibility features using NVDA and verify hCaptcha integration and screen reader compatibility.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/twlhitesh/DeepSeek-V3?shareId=XXXX-XXXX-XXXX-XXXX).
2025-01-06 15:53:37 +05:30

41 lines
1.4 KiB
Python

from flask import Flask, render_template, request, redirect, url_for, flash
import hcaptcha
app = Flask(__name__)
app.secret_key = 'your_secret_key'
# Configure hCaptcha
hcaptcha_site_key = 'your_hcaptcha_site_key'
hcaptcha_secret_key = 'your_hcaptcha_secret_key'
@app.route('/signup', methods=['GET', 'POST'])
def signup():
if request.method == 'POST':
hcaptcha_response = request.form['h-captcha-response']
if hcaptcha.verify(hcaptcha_secret_key, hcaptcha_response):
# Process the sign-up form
flash('Sign-up successful!', 'success')
return redirect(url_for('login'))
else:
flash('hCaptcha verification failed. Please try again.', 'danger')
return render_template('signup.html', hcaptcha_site_key=hcaptcha_site_key)
@app.route('/login', methods=['GET', 'POST'])
def login():
if request.method == 'POST':
hcaptcha_response = request.form['h-captcha-response']
if hcaptcha.verify(hcaptcha_secret_key, hcaptcha_response):
# Process the login form
flash('Login successful!', 'success')
return redirect(url_for('dashboard'))
else:
flash('hCaptcha verification failed. Please try again.', 'danger')
return render_template('login.html', hcaptcha_site_key=hcaptcha_site_key)
@app.route('/dashboard')
def dashboard():
return 'Welcome to the dashboard!'
if __name__ == '__main__':
app.run(debug=True)