-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-api.py
More file actions
61 lines (54 loc) · 1.38 KB
/
test-api.py
File metadata and controls
61 lines (54 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python3
"""
Simple test API for VPN system
"""
from flask import Flask, jsonify
from flask_cors import CORS
app = Flask(__name__)
CORS(app)
@app.route('/health')
def health():
return jsonify({'status': 'healthy', 'message': 'VPN API is running'})
@app.route('/api/status')
def status():
return jsonify({
'wireguard': {
'status': 'running',
'peers': 0,
'transfer_rx': 0,
'transfer_tx': 0
},
'system': {
'cpu_percent': 25.5,
'memory_percent': 50.0,
'disk_percent': 30.0
}
})
@app.route('/api/clients')
def clients():
return jsonify([
{
'id': 1,
'name': 'test-client',
'public_key': 'test-public-key',
'ip_address': '10.0.0.2',
'is_active': True,
'bytes_received': 1024,
'bytes_sent': 2048,
'created_at': '2024-01-01T00:00:00Z'
}
])
@app.route('/api/auth/login', methods=['POST'])
def login():
return jsonify({
'access_token': 'test-token-123',
'user': {
'id': 1,
'username': 'admin',
'email': 'admin@vpn.local',
'is_admin': True
}
})
if __name__ == '__main__':
print("Starting test API on http://localhost:8080")
app.run(host='0.0.0.0', port=8080, debug=True)