Coverage for app / main.py: 95%
22 statements
« prev ^ index » next coverage.py v7.13.0, created at 2025-12-16 13:09 +0000
« prev ^ index » next coverage.py v7.13.0, created at 2025-12-16 13:09 +0000
1from pathlib import Path
3import modal
4from fastapi import FastAPI
5from fastapi.staticfiles import StaticFiles
7from app.config import settings
8from app.routers import data, hypermedia
10web_app = FastAPI(title=settings.APP_NAME)
11app = modal.App("sql_translate")
14static_path = Path(__file__).parent.with_name("static").resolve()
15static_remote_path = "/assets/static"
16templates_path = Path(__file__).parent.with_name("templates").resolve()
17templates_remote_path = "/assets/templates"
18pyproject_toml_path = Path(__file__).parent.with_name("pyproject.toml").resolve()
20image = (
21 modal.Image.debian_slim(python_version="3.13")
22 .pip_install_from_pyproject(pyproject_toml_path)
23 .env({"ENVIRONMENT": "prod"})
24 .add_local_dir(static_path, remote_path=static_remote_path)
25 .add_local_dir(templates_path, remote_path=templates_remote_path)
26)
28static_files = (
29 StaticFiles(directory=static_remote_path)
30 if settings.ENVIRONMENT == "prod"
31 else StaticFiles(directory=static_path)
32)
34web_app.mount("/static", static_files, name="static")
36web_app.include_router(data.router)
37web_app.include_router(hypermedia.router)
40@app.function(image=image)
41@modal.asgi_app()
42def fastapi_app() -> FastAPI:
43 return web_app