backend/
__init__.py
main.py
database.py
models.py
dmca.py
requirements.txt
.env
.env.example
.gitignore
README.md
backend/.envis loaded automatically at startup.- Required:
SERPAPI_KEYIMGBB_KEY
Example (backend/.env.example):
SERPAPI_KEY=your_key_here
IMGBB_KEY=your_key_here
.gitignore is set up to ignore .env files.
- SQLite by default:
./app.db - Tables are created on app startup.
- Models:
Certificate(created by/upload)DmcaNotice(created byPOST /dmca)
Returns:
{ "status": "ok" }Accepts multipart form fields:
fileowner_nameowner_email
Behavior:
- Reads the file bytes
- Computes SHA-256:
hashlib.sha256(file_bytes).hexdigest() - Uploads bytes to ImgBB using
IMGBB_KEY - Saves a
Certificaterow in SQLite (includescertificate_idlikeCS-XXXXXXXXand a fakeblock_number) - Returns the full certificate object
Example:
curl -s -X POST "http://127.0.0.1:8000/upload" \
-F "owner_name=Jane Doe" \
-F "[email protected]" \
-F "file=@./my_image.png"Fetch a certificate (used by the QR-code verification page).
Example:
curl -s "http://127.0.0.1:8000/certificate/CS-XXXXXXXX"Reverse-image scan the certificate image using SerpApi and return matches with a computed risk_level.
Example:
curl -s -X POST "http://127.0.0.1:8000/scan" \
-H "Content-Type: application/json" \
-d '{ "certificate_id": "CS-XXXXXXXX" }'Generates a DMCA notice for a certificate + infringing URL, saves it to SQLite, and returns the DMCA text and contact info.
Example:
curl -s -X POST "http://127.0.0.1:8000/dmca" \
-H "Content-Type: application/json" \
-d '{
"certificate_id": "CS-XXXXXXXX",
"infringing_url": "https://example.com/infringing"
}'If you expose the backend via ngrok, you may need to send this header to bypass the free-tier browser warning page:
ngrok-skip-browser-warning: true
backend/dmca.py includes:
generate_dmca(cert, infringing_url) -> (dmca_text, abuse_contact, mailto_link)
It:
- Fills the provided DMCA template using fields from
cert - Uses a hardcoded abuse-contact map for common platforms and falls back to
abuse@[domain] - Returns a properly URL-encoded
mailto:link when the abuse contact is an email (otherwisemailto_linkis empty)
python3 -m pip install -r backend/requirements.txt
python3 -m uvicorn backend.main:app --reload