Update app.py
Browse files
app.py
CHANGED
|
@@ -1,25 +1,19 @@
|
|
| 1 |
-
from fastapi import FastAPI
|
| 2 |
from fastapi.responses import HTMLResponse
|
| 3 |
from fastapi.staticfiles import StaticFiles
|
| 4 |
from fastapi.templating import Jinja2Templates
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
from routes.generate import router as generate_router
|
| 8 |
-
from routes.image_edit import router as image_router
|
| 9 |
|
| 10 |
app = FastAPI(title="PyRunner AI Space")
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
|
| 15 |
|
| 16 |
-
app.include_router(health_router)
|
| 17 |
-
app.include_router(generate_router)
|
| 18 |
-
app.include_router(image_router)
|
| 19 |
|
| 20 |
@app.get("/", response_class=HTMLResponse)
|
| 21 |
async def home(request: Request):
|
| 22 |
-
return templates.TemplateResponse(
|
| 23 |
-
"index.html",
|
| 24 |
-
{"request": request}
|
| 25 |
-
)
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
from fastapi.responses import HTMLResponse
|
| 3 |
from fastapi.staticfiles import StaticFiles
|
| 4 |
from fastapi.templating import Jinja2Templates
|
| 5 |
+
from fastapi import Request
|
| 6 |
+
import os
|
|
|
|
|
|
|
| 7 |
|
| 8 |
app = FastAPI(title="PyRunner AI Space")
|
| 9 |
|
| 10 |
+
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
| 11 |
+
|
| 12 |
+
templates = Jinja2Templates(directory=os.path.join(BASE_DIR, "templates"))
|
| 13 |
|
| 14 |
+
app.mount("/static", StaticFiles(directory=os.path.join(BASE_DIR, "static")), name="static")
|
| 15 |
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
@app.get("/", response_class=HTMLResponse)
|
| 18 |
async def home(request: Request):
|
| 19 |
+
return templates.TemplateResponse("index.html", {"request": request})
|
|
|
|
|
|
|
|
|