38 lines
1.0 KiB
Python
38 lines
1.0 KiB
Python
"""
|
|
Jira Vein - FastAPI app.
|
|
"""
|
|
|
|
from pathlib import Path
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.responses import FileResponse, JSONResponse
|
|
from .api.routes import router
|
|
from .core.config import settings
|
|
|
|
app = FastAPI(title="Jira Vein", version="0.1.0")
|
|
app.include_router(router)
|
|
|
|
UI = Path(__file__).parent / "ui" / "index.html"
|
|
|
|
|
|
@app.get("/ui", include_in_schema=False)
|
|
def ui():
|
|
"""The vein's ad-hoc interface.
|
|
|
|
One file, served as-is. Its theme and its parts are baked in by
|
|
common/theme/bake.py, so this is a plain FileResponse rather than a
|
|
template: there is nothing left to fill in at request time, and the same
|
|
bytes open from a double-click when nothing is serving them.
|
|
"""
|
|
if not UI.is_file():
|
|
return JSONResponse(
|
|
{"error": "no ui/index.html", "hint": "run `make theme bake` from the spr root"},
|
|
status_code=404,
|
|
)
|
|
return FileResponse(UI, media_type="text/html")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
uvicorn.run(app, host="0.0.0.0", port=settings.api_port)
|