Spaces:
Sleeping
Sleeping
feat: serve index.html beautifully on root route
Browse files
main.py
CHANGED
|
@@ -1,4 +1,16 @@
|
|
| 1 |
from openenv.core.env_server import create_fastapi_app
|
| 2 |
from environment import CodeBugEnvironment
|
|
|
|
|
|
|
| 3 |
|
| 4 |
app = create_fastapi_app(CodeBugEnvironment)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from openenv.core.env_server import create_fastapi_app
|
| 2 |
from environment import CodeBugEnvironment
|
| 3 |
+
from fastapi.responses import HTMLResponse
|
| 4 |
+
import os
|
| 5 |
|
| 6 |
app = create_fastapi_app(CodeBugEnvironment)
|
| 7 |
+
|
| 8 |
+
@app.get("/")
|
| 9 |
+
def serve_frontend():
|
| 10 |
+
# Serve the beautiful frontend UI at the root Vercel/HF link!
|
| 11 |
+
html_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "templates", "index.html")
|
| 12 |
+
try:
|
| 13 |
+
with open(html_path, "r", encoding="utf-8") as f:
|
| 14 |
+
return HTMLResponse(f.read())
|
| 15 |
+
except:
|
| 16 |
+
return HTMLResponse("<h1>CodeBug API is Running.</h1><p>Visit /docs to see the OpenEnv logic.</p>")
|