Fix static asset serving in Modal app
This commit is contained in:
4
main.py
4
main.py
@@ -19,7 +19,7 @@ app = modal.App("formex-viewer", image=app_image)
|
|||||||
)
|
)
|
||||||
@modal.asgi_app()
|
@modal.asgi_app()
|
||||||
def fastapi_app():
|
def fastapi_app():
|
||||||
import fastapi.staticfiles
|
import fastapi
|
||||||
|
|
||||||
from formex_viewer.server import app as formex_app
|
from formex_viewer.server import app as formex_app
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ def fastapi_app():
|
|||||||
@formex_app.get("/{path:path}")
|
@formex_app.get("/{path:path}")
|
||||||
async def frontend_handler(path: str):
|
async def frontend_handler(path: str):
|
||||||
fp = assets_path / path
|
fp = assets_path / path
|
||||||
if not fp.exists():
|
if not fp.exists() or not fp.is_file():
|
||||||
fp = assets_path / "index.html"
|
fp = assets_path / "index.html"
|
||||||
return fastapi.responses.FileResponse(fp)
|
return fastapi.responses.FileResponse(fp)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user