Skip to content
2006-skPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

BackendSJhacks (Backend)

What’s implemented

Project structure

backend/
  __init__.py
  main.py
  database.py
  models.py
  dmca.py
  requirements.txt
  .env
  .env.example
.gitignore
README.md

Environment variables

  • backend/.env is loaded automatically at startup.
  • Required:
    • SERPAPI_KEY
    • IMGBB_KEY

Example (backend/.env.example):

SERPAPI_KEY=your_key_here
IMGBB_KEY=your_key_here

.gitignore is set up to ignore .env files.

Database

  • SQLite by default: ./app.db
  • Tables are created on app startup.
  • Models:
    • Certificate (created by /upload)
    • DmcaNotice (created by POST /dmca)

API

GET /health

Returns:

{ "status": "ok" }

POST /upload

Accepts multipart form fields:

  • file
  • owner_name
  • owner_email

Behavior:

  • Reads the file bytes
  • Computes SHA-256: hashlib.sha256(file_bytes).hexdigest()
  • Uploads bytes to ImgBB using IMGBB_KEY
  • Saves a Certificate row in SQLite (includes certificate_id like CS-XXXXXXXX and a fake block_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"

GET /certificate/{certificate_id}

Fetch a certificate (used by the QR-code verification page).

Example:

curl -s "http://127.0.0.1:8000/certificate/CS-XXXXXXXX"

POST /scan

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" }'

POST /dmca

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"
  }'

Ngrok

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

DMCA helper

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 (otherwise mailto_link is empty)

Setup & run

python3 -m pip install -r backend/requirements.txt
python3 -m uvicorn backend.main:app --reload

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages