develop #2
37
serve_ui.py
37
serve_ui.py
|
|
@ -1,37 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
Simple HTTP server to serve the UI files
|
||||
"""
|
||||
import http.server
|
||||
import socketserver
|
||||
import os
|
||||
import webbrowser
|
||||
from pathlib import Path
|
||||
|
||||
# Change to the ui directory
|
||||
ui_dir = Path(__file__).parent / "ui"
|
||||
os.chdir(ui_dir)
|
||||
|
||||
PORT = 3000
|
||||
|
||||
class MyHTTPRequestHandler(http.server.SimpleHTTPRequestHandler):
|
||||
def end_headers(self):
|
||||
self.send_header('Access-Control-Allow-Origin', '*')
|
||||
self.send_header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS')
|
||||
self.send_header('Access-Control-Allow-Headers', 'Content-Type')
|
||||
super().end_headers()
|
||||
|
||||
if __name__ == "__main__":
|
||||
with socketserver.TCPServer(("", PORT), MyHTTPRequestHandler) as httpd:
|
||||
print(f"🌐 Serving UI at http://localhost:{PORT}")
|
||||
print(f"📁 Serving files from: {ui_dir.absolute()}")
|
||||
print("💡 Make sure the API server is running on http://localhost:8000")
|
||||
print("🔄 Press Ctrl+C to stop")
|
||||
|
||||
# Try to open browser
|
||||
try:
|
||||
webbrowser.open(f"http://localhost:{PORT}")
|
||||
except:
|
||||
pass
|
||||
|
||||
httpd.serve_forever()
|
||||
|
|
@ -56,7 +56,16 @@ app = FastAPI(
|
|||
title="AI Lab API",
|
||||
description="API for various AI/ML pipelines using transformers",
|
||||
version="1.0.0",
|
||||
lifespan=lifespan
|
||||
lifespan=lifespan,
|
||||
swagger_ui_parameters={
|
||||
"defaultModelsExpandDepth": -1,
|
||||
"syntaxHighlight.theme": "obsidian",
|
||||
"tryItOutEnabled": True,
|
||||
"requestSnippetsEnabled": True,
|
||||
"persistAuthorization": True,
|
||||
"displayRequestDuration": True,
|
||||
"defaultModelRendering": "model"
|
||||
}
|
||||
)
|
||||
|
||||
# Add CORS middleware
|
||||
|
|
|
|||
Loading…
Reference in New Issue