Basic Static Files
Serve files from a directory at a path prefix:
from justapi import JustAPIApp
app = JustAPIApp()
app.frontend("/static", "static")
This serves files from the static/ directory at /static/. For example, static/style.css is accessible at /static/style.css.
Custom Mount Point
# Serve at /assets/*
app.frontend("/assets", "public/assets")
Multiple Static Directories
app.frontend("/css", "static/css")
app.frontend("/js", "static/js")
app.frontend("/images", "static/images")
Mounting an APIRouter as a Sub-application
JustAPI supports mounting an APIRouter at a path prefix:
from justapi import APIRouter, JustAPIApp
app = JustAPIApp()
# Serve a static SPA with index.html fallback for client-side routing
app.frontend("/", "public", html=True)
# Mount a router as a sub-application
router = APIRouter(prefix="/api/v2")
app.mount("/api/v2", router, name="v2")
JustAPI does not mount third-party ASGI/Starlette applications — the runtime is a native Rust pipeline. Use
APIRouterfor sub-app structure, or place JustAPI behind a path-routing reverse proxy to co-host legacy apps.
See Also
- Response Classes — response types
- Custom Response Classes — HTML, stream, file responses
- Deployment — Docker — containerized static files