- Email Verification Login: Login using @wku.edu.cn email + verification code
- User Data Management: Automatically store user dormitory information to JSON files
- Scheduled Query System: Automatically query all users' water and electricity bills at 9 AM daily
- Intelligent Push Notifications: Calculate yesterday's usage and push to iOS devices
- Database Storage: SQLite database storage for query history records
- Asynchronous Email Sending: Based on Celery + Redis asynchronous task queue
- APNs Push Service: Asynchronous iOS push notification service
- RESTful API: Provides standardized API interfaces
- Redis Caching: Verification code storage and expiration management
- Data Statistics: Provides user statistics and query history analysis
iOS Client ←→ Flask API ←→ Redis ←→ Celery Worker ←→ SMTP Service
- iOS client sends email address to API
- API generates verification code stored in Redis, and sends email asynchronously via Celery
- User enters verification code for verification
- User selects dormitory information (building, floor, room)
- Client sends verification code and dormitory information together to server
- Server verifies verification code and saves user dormitory information to JSON file
- Login successful, access granted
- Python 3.7+
- Redis server
- SMTP email service (Gmail recommended)
cd cardQuery
pip install -r requirements.txt# Copy configuration template
cp doNotUpload.env.example doNotUpload.env
# Edit configuration file with actual values
nano doNotUpload.envConfiguration details:
SMTP_USER: Gmail email addressSMTP_PASS: Gmail app-specific passwordREDIS_HOST: Redis server addressAPI_PORT: API service port
# Use startup script (recommended)
python start_server.py
# Or start manually
# Start Celery Worker
celery -A verification_service.celery worker --loglevel=info
# Start Flask API (new terminal)
python app.py# View user registration info and dormitory distribution
python view_users.pyFeatures provided:
- Total user count statistics
- Building distribution
- Detailed user information list
- Detailed distribution by building and floor
# View water and electricity bill query history records
python view_query_history.pyFeatures provided:
- Query record statistics
- Recent query record viewing
- Specific user query history
- Query failure analysis
- Old data cleanup
- Auto Execution: Automatically query all users' water and electricity bills at 9 AM daily
- Intelligent Push: Automatically calculate yesterday's usage and push notifications to iOS devices
- Anti-Crawling: 20-second interval between users, 10-second interval between electricity/water queries
- Database Storage: Query results stored in SQLite database
- Usage Analysis: Automatically calculate usage difference from yesterday
- Manual Trigger: Support manual query triggering via API
- Progress Display: Real-time display of query progress and estimated time
- Failure Retry: Automatically handle query failures
- Data Cleanup: Automatically clean records older than 90 days
- Email Verification: Only allows @wku.edu.cn email login
- Verification Code Expiration: Verification codes expire after 5 minutes
- Local Storage: Sensitive data stored only on local device
- Secure Communication: All network requests use HTTPS encryption
POST /api/send_code
Content-Type: application/json
{
"email": "student@wku.edu.cn"
}POST /api/verify_code
Content-Type: application/json
{
"email": "student@wku.edu.cn",
"code": "123456"
}POST /api/verify_code_with_room
Content-Type: application/json
{
"email": "student@wku.edu.cn",
"code": "123456",
"room_info": {
"building_code": "237",
"building_name": "Building 4 (Ju Yuan)",
"floor_code": "2",
"floor_name": "Floor 2",
"room_code": "10237201",
"room_name": "237201"
}
}GET /api/user_info/{email}GET /api/users_statsGET /api/query_history/{email}GET /api/scheduler/statusPOST /api/scheduler/manual_query
Content-Type: application/json
{
"email": "student@wku.edu.cn" // Optional, query all users if empty
}POST /api/device_token
Content-Type: application/json
{
"email": "student@wku.edu.cn",
"device_token": "device push token"
}GET /api/device_token/{email}GET /api/health- Enable two-factor authentication
- Generate app-specific password
- Use app-specific password in environment configuration
Ensure Redis service is running properly:
# Start Redis (Ubuntu/CentOS)
sudo systemctl start redis
# Check status
redis-cli ping- Environment Isolation: cardQuery (server) and cardQueryApp_ios (client) are independent projects
- Configuration Files: doNotUpload.env contains sensitive information, do not upload to version control
- Email Restriction: Only supports @wku.edu.cn suffix email addresses
- Dormitory Binding: Dormitory information is bound during first login and cannot be modified later; re-register if changes needed
- Data Backup:
- User data stored in
users_data.jsonfile - Query history stored in
cardquery_data.dbdatabase - Please backup these important files regularly
- User data stored in
- Scheduled Tasks: Scheduled query tasks start automatically when server starts, no manual configuration needed
- Anti-Crawling: System implements 20-second user intervals and 10-second query intervals
- Push Function: Supports iOS APNs push for yesterday's usage statistics
- APNs Configuration: Apple push certificates must be configured to use push functionality
- Query Duration: Large-scale user queries require significant time, please schedule tasks appropriately
- Database Maintenance: System automatically cleans query records older than 90 days
- Network Requirements: Ensure client can access server API address
Welcome to submit issues and improvement suggestions! Please ensure:
- Follow existing code style
- Add necessary comments and documentation
- Test new feature stability