-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
62 lines (46 loc) · 1.63 KB
/
Copy pathapp.py
File metadata and controls
62 lines (46 loc) · 1.63 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
62
#!/usr/bin/env python3
"""
Flask server for 19" Rack Mount Generator
Serves static files only - STL generation happens client-side via Three.js
"""
from flask import Flask, send_from_directory, jsonify
import sys
app = Flask(__name__, static_folder='.', static_url_path='')
@app.route('/')
def index():
"""Serve the main HTML file"""
return send_from_directory('.', 'index.html')
@app.route('/api/health', methods=['GET'])
def health_check():
"""Health check endpoint"""
from datetime import datetime
return jsonify({
'status': 'ok',
'timestamp': datetime.now().isoformat(),
'version': '2.0.0',
'mode': 'client-side STL export'
}), 200
@app.errorhandler(404)
def not_found(error):
"""Handle 404 errors"""
return jsonify({'error': 'Not found'}), 404
@app.errorhandler(500)
def internal_error(error):
"""Handle 500 errors"""
return jsonify({'error': 'Internal server error'}), 500
if __name__ == '__main__':
print("🚀 Starting 19\" Rack Mount Generator Server")
print("📍 Open http://localhost:5001 in your browser")
print("\nServer running on http://127.0.0.1:5001")
# Parse host and port from arguments
host = '127.0.0.1'
port = 5001 # Use 5001 since macOS ControlCenter uses 5000
if '--host' in sys.argv:
host_idx = sys.argv.index('--host')
if host_idx + 1 < len(sys.argv):
host = sys.argv[host_idx + 1]
if '--port' in sys.argv:
port_idx = sys.argv.index('--port')
if port_idx + 1 < len(sys.argv):
port = int(sys.argv[port_idx + 1])
app.run(debug=True, host=host, port=port)