servidor.py), which provides a straightforward REST API for managing one ZKTeco biometric device.
Overview
The single-device server is ideal for:- Small offices with one biometric device
- Testing and development environments
- Simple deployment scenarios without device management overhead
Prerequisites
Environment Variables
Configure the server by setting these environment variables before starting:Device Connection
| Variable | Default | Description |
|---|---|---|
ZK_IP | 192.168.1.205 | IP address of the ZKTeco device |
ZK_PORT | 4370 | Port number of the device |
ZK_PASSWORD | 0 | Device password (typically 0) |
ZK_TIMEOUT | 5 | Connection timeout in seconds |
Server Configuration
| Variable | Default | Description |
|---|---|---|
API_HOST | 0.0.0.0 | Server listening interface |
API_PORT | 5000 | Server port |
CERT_FILE | cert.pem | SSL certificate file path |
KEY_FILE | key.pem | SSL private key file path |
Starting the Server
- Direct Execution
- With Environment Variables
- Production (systemd)
- Check for existing SSL certificates
- Generate self-signed certificates if
pyopensslis installed - Start in HTTPS mode (with certificates) or HTTP mode (without)
Verifying the Connection
After starting the server, verify the setup:Common Operations
User Management
List All Users
List All Users
uid, user_id, name, privilege, and card for each user.Create a New User
Create a New User
0- Regular user14- Administrator
Update User Information
Update User Information
Delete a User
Delete a User
Fingerprint Enrollment
Start Enrollment Mode
Activate fingerprint enrollment for a user:Finger Index Values:
0- Right thumb1- Right index finger2- Right middle finger3- Right ring finger4- Right little finger5- Left thumb6- Left index finger7- Left middle finger8- Left ring finger9- Left little finger
User Places Finger
The device enters enrollment mode. The user must place their finger on the device 3 times when prompted.
Device Time Management
Deployment Scenarios
Local Network Access
Internet-Facing Deployment
Troubleshooting
Connection Timeout
Connection Timeout
Error:
Connection timeout or Unable to connect to deviceSolutions:- Verify the device IP address is correct
- Check network connectivity:
ping 192.168.1.205 - Ensure the device port is accessible
- Increase
ZK_TIMEOUTenvironment variable - Check firewall rules on both server and device
SSL Certificate Errors
SSL Certificate Errors
Error:
SSL certificate verification failedSolutions:- If using self-signed certificates, use
-kflag with curl: - For production, use proper SSL certificates (Let’s Encrypt)
- Disable HTTPS by not installing
pyopenssl
Device Locked/Busy
Device Locked/Busy
Error:
Device is locked or Device busySolutions:- The device can handle only one connection at a time
- Wait for previous request to complete
- Restart the device if it remains locked
- Check for other applications connected to the device
Empty Attendance Records
Empty Attendance Records
Error: Attendance endpoint returns empty arraySolutions:
- Verify users have clocked in/out on the device
- Check the device’s internal memory
- Verify date filters aren’t excluding records
- Ensure device time is synchronized
Performance Considerations
The single-device server queries the device in real-time for every request. Large attendance datasets may take longer to retrieve.
- Attendance Records: Retrieving thousands of records may take 5-30 seconds depending on device model
- Concurrent Requests: The server uses threading locks to prevent simultaneous device access
- Network Latency: Keep server and device on the same local network for best performance
Next Steps
Multi-Device Setup
Scale to multiple devices with centralized management
SSL Configuration
Secure your deployment with proper SSL/TLS
API Reference
Complete API endpoint documentation
Environment Variables
Full configuration reference