Barcode / QR code access control system for universities.
| File | Purpose |
|---|---|
scanner_app.py |
Python backend — camera scanner + REST API |
scanner_ui.html |
Web dashboard — live results + scan history |
pip install opencv-python pyzbar pillow flask flask-corsLinux only: also run
sudo apt install libzbar0
Edit the students_db dict in scanner_app.py:
students_db = {
"STU-2024-001": {"name": "Alice Johnson", "department": "CS", "year": 3},
...
}Or load from CSV (see load_from_csv() example at the bottom of the file).
python scanner_app.pyThis opens your webcam and starts the REST API on http://localhost:5000.
Open scanner_ui.html in your browser.
Use Manual / Demo Scan to test without a physical card.
STU-2024-001 Alice Johnson Computer Science Year 3
STU-2024-002 Bob Martinez Engineering Year 2
STU-2024-003 Clara Nguyen Medicine Year 4
STU-2024-004 David Osei Business Year 1
STU-2024-005 Eva Chen Law Year 5
| Endpoint | Method | Description |
|---|---|---|
/api/last_scan |
GET | Most recent scan result |
/api/log |
GET | Scan history (up to 200) |
/api/stats |
GET | Totals: granted / denied |
/api/manual_scan |
POST {"code": "STU-..."} |
Simulate a scan |
Add this to scanner_app.py and call it before scan_loop():
import pandas as pd
def load_from_csv(path="students.csv"):
df = pd.read_csv(path) # columns: id, name, department, year
for _, row in df.iterrows():
students_db[row["id"]] = {
"name": row["name"],
"department": row["department"],
"year": int(row["year"]),
}CSV format (students.csv):
id,name,department,year
STU-2024-001,Alice Johnson,Computer Science,3