Simple localhost web app for drinks balances.
- Search by name or student number.
- Scan a barcode with a physical scanner into the search bar.
- Search accepts scanner values with a 3-character prefix before the stored student number.
- Clear the search with one button.
- Buy one drink (
-$1.00) from their balance. - Student numbers are searchable but hidden in the public members table.
- Add members.
- Remove members.
- Search and select a member to edit.
- Update name and student number.
- Add/subtract from existing balance.
- Update the drink price.
- Admin auto-locks when switching back to the Members tab.
- Export current members database to CSV.
- Initialize/replace database from exported CSV.
From this folder:
python3 server.pyOpen:
The Members search box is designed for a keyboard-wedge barcode scanner. It stays focused, accepts scanned values like xxx12345678, strips the 3-character prefix for matching, allows normal keyboard typing, and auto-clears after 1 minute.
Database file is local SQLite at:
./drinks_tab.db
All member changes are logged in:
member_audit_logtable (add/edit/purchase/remove/balance changes)
Install as a system service:
cd /absolute/path/to/drinks_tab
sudo bash deploy/install_system_service.shIf you previously installed an older unit file, reinstall to overwrite it:
sudo systemctl disable --now croc-drinks-tab.service
cd /absolute/path/to/drinks_tab
sudo bash deploy/install_system_service.shService commands:
sudo systemctl start croc-drinks-tab.service
sudo systemctl stop croc-drinks-tab.service
sudo systemctl restart croc-drinks-tab.service
sudo systemctl status croc-drinks-tab.service
sudo journalctl -u croc-drinks-tab.service -fDisable auto-start:
sudo systemctl disable croc-drinks-tab.serviceIf the service shows running but frontend cannot connect, verify on the laptop:
curl -v http://127.0.0.1:8000/api/members
sudo systemctl status croc-drinks-tab.service --no-pager -l
sudo journalctl -u croc-drinks-tab.service -n 120 --no-pagerRuntime/service logs (server stdout/stderr) are in systemd journal:
sudo journalctl -u croc-drinks-tab.service
sudo journalctl -u croc-drinks-tab.service -fMember activity logs (add/edit/purchase/remove/balance changes) are stored in SQLite table member_audit_log inside ./drinks_tab.db.
Example query:
sqlite3 ./drinks_tab.db \
"SELECT datetime(event_time_ms/1000,'unixepoch','localtime'), action, actor, member_name, balance_before, balance_after, balance_delta FROM member_audit_log ORDER BY id DESC LIMIT 20;"GET /api/members?search=<name_or_student_number>POST /api/purchasebody:{ "id": 1 }POST /api/admin/loginheader:X-Admin-Password: ****POST /api/admin/addheader:X-Admin-Password: ****POST /api/admin/removeheader:X-Admin-Password: ****POST /api/admin/edit-memberheader:X-Admin-Password: ****- body:
{ "id": 1, "name": "Alice", "studentNumber": "12345678", "balanceDelta": 2.0 }
- body:
GET /api/admin/export-csvheader:X-Admin-Password: ****POST /api/admin/import-csvheader:X-Admin-Password: ****- body:
{ "csv": "Name,StudentNumber,Balance\\nAlice,12345678,5.00\\n" }
- body:
POST /api/admin/set-drink-priceheader:X-Admin-Password: ****- body:
{ "drinkPrice": 1.50 }
- body: