Spaces:
Paused
Paused
alessandro trinca tornidor
commited on
Commit
•
19270a8
1
Parent(s):
c13c67e
bug: fix missing Path cast
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import logging
|
2 |
import os
|
3 |
import sys
|
|
|
4 |
|
5 |
import gradio as gr
|
6 |
import uvicorn
|
@@ -24,22 +25,22 @@ FASTAPI_TITLE = "lisa_app"
|
|
24 |
app = FastAPI(title=FASTAPI_TITLE, version="1.0")
|
25 |
app.include_router(routes.router)
|
26 |
|
27 |
-
|
28 |
frontend_builder.build_frontend(
|
29 |
project_root_folder=frontend_builder.env_project_root_folder,
|
30 |
input_css_path=frontend_builder.env_input_css_path,
|
31 |
-
output_dist_folder=
|
32 |
)
|
33 |
|
34 |
logging.info("build_frontend ok!")
|
35 |
|
36 |
os.makedirs(utils.FASTAPI_STATIC, exist_ok=True)
|
37 |
-
app.mount(CUSTOM_STATIC_PATH, StaticFiles(directory=
|
38 |
|
39 |
|
40 |
@app.get(CUSTOM_STATIC_PATH)
|
41 |
async def static() -> FileResponse:
|
42 |
-
return FileResponse(path=str(
|
43 |
|
44 |
|
45 |
templates = Jinja2Templates(directory="templates")
|
|
|
1 |
import logging
|
2 |
import os
|
3 |
import sys
|
4 |
+
from pathlib import Path
|
5 |
|
6 |
import gradio as gr
|
7 |
import uvicorn
|
|
|
25 |
app = FastAPI(title=FASTAPI_TITLE, version="1.0")
|
26 |
app.include_router(routes.router)
|
27 |
|
28 |
+
fastapi_dict_folder = Path(utils.FASTAPI_STATIC) / "dist"
|
29 |
frontend_builder.build_frontend(
|
30 |
project_root_folder=frontend_builder.env_project_root_folder,
|
31 |
input_css_path=frontend_builder.env_input_css_path,
|
32 |
+
output_dist_folder=fastapi_dict_folder
|
33 |
)
|
34 |
|
35 |
logging.info("build_frontend ok!")
|
36 |
|
37 |
os.makedirs(utils.FASTAPI_STATIC, exist_ok=True)
|
38 |
+
app.mount(CUSTOM_STATIC_PATH, StaticFiles(directory=fastapi_dict_folder), name="static")
|
39 |
|
40 |
|
41 |
@app.get(CUSTOM_STATIC_PATH)
|
42 |
async def static() -> FileResponse:
|
43 |
+
return FileResponse(path=str(fastapi_dict_folder / "index.html"), media_type="text/html")
|
44 |
|
45 |
|
46 |
templates = Jinja2Templates(directory="templates")
|