Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,13 @@
|
|
| 1 |
import uvicorn
|
| 2 |
import os
|
| 3 |
-
from fastapi import
|
|
|
|
|
|
|
|
|
|
| 4 |
from fastapi.openapi.docs import (
|
| 5 |
get_swagger_ui_html,
|
| 6 |
get_swagger_ui_oauth2_redirect_html,
|
| 7 |
)
|
| 8 |
-
from pyngrok import ngrok
|
| 9 |
from starlette.middleware.cors import CORSMiddleware
|
| 10 |
|
| 11 |
from core.config import settings
|
|
@@ -25,6 +27,14 @@ app = FastAPI(
|
|
| 25 |
# docs_url=None,
|
| 26 |
)
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
@app.on_event("startup")
|
| 30 |
async def startup():
|
|
@@ -83,8 +93,7 @@ def run():
|
|
| 83 |
reload_dirs.remove(dir)
|
| 84 |
except:
|
| 85 |
pass
|
| 86 |
-
|
| 87 |
-
print("Public URL:", public_url)
|
| 88 |
uvicorn.run(
|
| 89 |
"app:app",
|
| 90 |
host=settings.BACKEND_HOST,
|
|
|
|
| 1 |
import uvicorn
|
| 2 |
import os
|
| 3 |
+
from fastapi import FastAPI4
|
| 4 |
+
from fastapi.templating import Jinja2Templates
|
| 5 |
+
from fastapi import FastAPI, Request
|
| 6 |
+
from fastapi.responses import HTMLResponse
|
| 7 |
from fastapi.openapi.docs import (
|
| 8 |
get_swagger_ui_html,
|
| 9 |
get_swagger_ui_oauth2_redirect_html,
|
| 10 |
)
|
|
|
|
| 11 |
from starlette.middleware.cors import CORSMiddleware
|
| 12 |
|
| 13 |
from core.config import settings
|
|
|
|
| 27 |
# docs_url=None,
|
| 28 |
)
|
| 29 |
|
| 30 |
+
templates = Jinja2Templates(directory="templates")
|
| 31 |
+
|
| 32 |
+
# Your other app code remains the same
|
| 33 |
+
|
| 34 |
+
@app.get("/", response_class=HTMLResponse)
|
| 35 |
+
async def read_root(request: Request):
|
| 36 |
+
# Render the index.html template
|
| 37 |
+
return templates.TemplateResponse("index.html", {"request": request})
|
| 38 |
|
| 39 |
@app.on_event("startup")
|
| 40 |
async def startup():
|
|
|
|
| 93 |
reload_dirs.remove(dir)
|
| 94 |
except:
|
| 95 |
pass
|
| 96 |
+
|
|
|
|
| 97 |
uvicorn.run(
|
| 98 |
"app:app",
|
| 99 |
host=settings.BACKEND_HOST,
|