-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_web.py
More file actions
66 lines (55 loc) · 1.75 KB
/
start_web.py
File metadata and controls
66 lines (55 loc) · 1.75 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
63
64
65
66
#!/usr/bin/env python3
"""
Web Application Launcher for Task Manager
"""
import http.server
import socketserver
import os
import sys
import webbrowser
import time
PORT = 3000
class CustomHandler(http.server.SimpleHTTPRequestHandler):
def do_GET(self):
if self.path == '/':
self.path = '/index.html'
return super().do_GET()
def end_headers(self):
self.send_header('Cache-Control', 'no-cache, no-store, must-revalidate')
self.send_header('Pragma', 'no-cache')
self.send_header('Expires', '0')
super().end_headers()
def main():
web_dir = os.path.join(os.path.dirname(__file__), 'mobile-app', 'web')
if not os.path.exists(web_dir):
print(f"Error: Web directory not found: {web_dir}")
return
os.chdir(web_dir)
print("=" * 60)
print("TASK MANAGER WEB APPLICATION")
print("=" * 60)
print(f"Web directory: {os.getcwd()}")
print(f"Web server: http://localhost:{PORT}")
print(f"FastAPI backend: http://localhost:8000")
print(f"API docs: http://localhost:8000/docs")
print("=" * 60)
print("Press Ctrl+C to stop")
print("=" * 60)
def open_browser():
time.sleep(2)
webbrowser.open(f'http://localhost:{PORT}')
import threading
browser_thread = threading.Thread(target=open_browser)
browser_thread.daemon = True
browser_thread.start()
try:
with socketserver.TCPServer(("", PORT), CustomHandler) as httpd:
print(f"Web server started on port {PORT}")
print("Opening browser...")
httpd.serve_forever()
except KeyboardInterrupt:
print("\nWeb server stopped")
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
main()