CoolFace
Apppublic

itsmrop/innovative-project

sourceHugging Faceupdated 4mo agoView on Hugging Face
0likes
App README

Innovative Samples Backend

REST API for the link-based captcha and sentence classification project.

Endpoints

  • —GET / — health check
  • —GET /api/session — returns a random captcha image and sentence
  • —POST /api/submit — validates captcha and classification, stores response

Security

  • —Signed, expiring, one-time session tokens (HMAC-SHA256)
  • —Per-IP rate limiting on session creation and submission
  • —Session lockout after repeated failed captcha attempts
  • —Security headers (nosniff, frame denial, no-store cache)
  • —Configurable CORS via ALLOWED_ORIGINS

Environment variables

VariableDefaultDescription
SESSION_SECRETdev fallbackSecret for signing session tokens
SESSION_TTL_SECONDS900Session expiry in seconds
MAX_FAILED_ATTEMPTS5Failed captcha attempts before lockout
ALLOWED_ORIGINS*Comma-separated frontend origins
RATE_LIMIT_SESSION_REQUESTS30Max session requests per IP per hour
RATE_LIMIT_SUBMIT_REQUESTS20Max submit requests per IP per hour

Local development

bash
pip install -r requirements.txt
uvicorn app:app --reload --port 7860

Docker

bash
docker build -t innovative-samples-api .
docker run -p 7860:7860 innovative-samples-api