A simple but powerful math-based CAPTCHA system built with Python, Flask, and Pillow.
It helps prevent bots by asking users to solve a basic math problem before verification.
👉 Live Demo: Math CAPTCHA on PythonAnywhere
- 🔢 Random math problems using
+,-, and* - 🖼️ Captcha images dynamically generated with Pillow (
captcha.ttffont) - ⚡ Clean & responsive Flask web UI with inline HTML/CSS
- ✅ Session-based verification with 10-minute expiry
- 🔁 Redirects verified users to another page (currently The India Ledger)
- 🖥️ Works both as:
- Standalone script (generates PNG locally)
- Flask web app (interactive UI + validation)
- Python 3.x
- Flask – Web framework
- Pillow (PIL) – Image generation
- HTML + CSS – Styled interface
- Docker (optional, for containerized deployment)
Script Version (Generated PNG):
Web App (Flask UI):
git clone https://github.com/Aditya-jaiswal07972/Math-Based-Captcha.git
cd Math-Based-Captchapip install -r requirements.txtGenerates a static out.png captcha image.
python python-captha.pyServes an interactive math CAPTCHA in your browser.
pip install flask pillow
python app.pyThen visit: 👉 http://127.0.0.1:5000/
docker build -t math-captcha .
docker run -p 5000:5000 math-captchaSECRET_KEY→ should be set as an environment variable in productionEXPIRY_SECONDS→ default 600 (10 minutes), controls verification validitycaptcha.ttf→ custom font for rendering; falls back to default if missing
This project is licensed under the MIT License. © 2025 Aadi (Aditya Jaiswal)

