-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_app.py
More file actions
33 lines (27 loc) · 1.09 KB
/
Copy pathstart_app.py
File metadata and controls
33 lines (27 loc) · 1.09 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
import uvicorn
import webbrowser
import os
import sys
import threading
import time
def open_browser():
"""Wait a bit for server to start, then open browser."""
time.sleep(1.5)
webbrowser.open("http://localhost:8000")
def check_build():
"""Check if frontend build exists."""
if not os.path.exists(os.path.join("web", "dist")):
print("Warning: Frontend build not found in 'web/dist'.")
print("Please run 'cd web && npm run build' first.")
# We don't exit here, just warn, in case user only wants API
if __name__ == "__main__":
check_build()
print("Starting LaTexRender App...")
print("Serving at http://localhost:8000")
# Open browser in a separate thread
threading.Thread(target=open_browser, daemon=True).start()
# Start server
# We use 'server.main:app' string to enable potential reload if needed,
# but here we use direct import for simplicity in a script or just call run
# To keep it simple and consistent with uvicorn CLI:
uvicorn.run("server.main:app", host="0.0.0.0", port=8000, reload=False)