A simple, lightweight loyalty card scanner application built with HTML, CSS, JavaScript, and Python Flask.
Claude code audited ScannerAPP code and rewrote it in HTML/CSS/JS & Python.
- QR Code Scanning: Camera-based QR code scanning using jsQR library
- Manual Input: Enter card codes manually if camera isn't available
- Customer Management: Automatic customer creation and lookup
- Points System: Add loyalty points to customer accounts
- Activity Logging: Track recent scanning activity
- Responsive Design: Works on desktop and mobile devices
- Offline Capability: Local storage for activity history
- Frontend: HTML5, CSS3, JavaScript (ES6+)
- Backend: Python Flask
- Database: JSON file (simple file-based storage)
- Libraries: jsQR for QR code detection, Flask-CORS for API access
pip install -r requirements.txtpython app.pyOpen your browser and go to: http://localhost:5000
The app comes with pre-loaded test customers:
- CARD001 - John Smith (150 points)
- CARD002 - Sarah Johnson (75 points)
- CARD003 - Mike Brown (300 points)
- 12345 - Demo Customer (100 points)
- Click "Start Scanner" to activate your camera
- Point the camera at a QR code containing a customer ID
- The app will automatically detect and process the code
- Customer information will be displayed
- Type a customer ID in the "Enter card code manually" field
- Click "Submit" or press Enter
- The system will look up or create the customer
- After scanning a customer card, their information will appear
- Enter the number of points to add (1-1000)
- Click "Add Points" to update their account
- All scanning and point-adding activities are logged
- History is saved locally in your browser
- Shows the last 10 activities with timestamps
The Flask backend provides these REST API endpoints:
POST /api/process-scan- Process a scanned QR codePOST /api/add-points- Add points to a customerGET /api/customers- Get all customersGET /api/customer/<id>- Get specific customerGET /api/stats- Get system statistics
DevScanner05/
βββ index.html # Main HTML file
βββ style.css # Styling and responsive design
βββ script.js # Frontend JavaScript logic
βββ app.py # Flask backend server
βββ requirements.txt # Python dependencies
βββ customers.json # Customer database (created automatically)
βββ README.md # This file
Customers are automatically created when scanning new codes, or you can manually add them to customers.json:
{
"NEWCARD": {
"id": "NEWCARD",
"name": "Customer Name",
"email": "[email protected]",
"phone": "+1-555-0000",
"points": 0,
"joinDate": "2024-07-27",
"totalVisits": 1,
"lastVisit": "2024-07-27"
}
}Modify style.css to change colors, fonts, or layout. The design uses CSS Grid and Flexbox for responsive layouts.
Edit app.py to:
- Change the database to PostgreSQL, MySQL, etc.
- Add authentication and user management
- Implement more complex business logic
- Add email notifications or integrations
For QR code scanning to work:
- Chrome/Safari: Allow camera access when prompted
- Mobile: Ensure camera permissions are enabled for your browser
- HTTPS: Camera access requires HTTPS in production (works on localhost for development)
To access from other devices on your network:
python app.py
# App will be available at http://YOUR_IP:5000For production deployment:
- Use a proper database (PostgreSQL, MySQL)
- Set up HTTPS (required for camera access)
- Use a production WSGI server (Gunicorn, uWSGI)
- Configure environment variables for sensitive data
Example with Gunicorn:
pip install gunicorn
gunicorn -w 4 -b 0.0.0.0:5000 app:app- Chrome: Full support
- Firefox: Full support
- Safari: Full support (iOS 11+)
- Edge: Full support
- Check browser permissions
- Ensure you're on HTTPS (production) or localhost (development)
- Try refreshing the page
- Use manual input as fallback
- Check if Python and Flask are installed
- Verify port 5000 is available
- Check for error messages in terminal
- Check browser console for errors
- Ensure customer is selected first
- Verify backend server is running
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
MIT License - feel free to use and modify for your projects.
For issues or questions:
- Check the troubleshooting section
- Look at browser console for error messages
- Create an issue on GitHub