ovdashboard/api/ovdashboard_api/main.py

43 lines
873 B
Python
Raw Normal View History

2022-08-28 23:59:57 +00:00
#!/usr/bin/env python3
"""
2022-08-31 18:26:07 +00:00
Main executable of `ovdashboard_api`.
2022-08-28 23:59:57 +00:00
Creates the main `FastAPI` app.
If run directly, uses `uvicorn` to run the app.
"""
import uvicorn
from fastapi import FastAPI
from .config import SETTINGS
from .routers import main_router
app = FastAPI(
2022-08-31 18:26:07 +00:00
title="OVDashboard API",
description="This API enables the `OVDashboard` service.",
2022-08-28 23:59:57 +00:00
contact={
"name": "Jörn-Michael Miehe",
"email": "jmm@yavook.de",
2022-08-28 23:59:57 +00:00
},
openapi_url=SETTINGS.openapi_url,
docs_url=SETTINGS.docs_url if not SETTINGS.production_mode else None,
redoc_url=SETTINGS.redoc_url if not SETTINGS.production_mode else None,
)
app.include_router(main_router)
2022-08-28 23:31:17 +00:00
def main() -> None:
2022-08-28 23:59:57 +00:00
uvicorn.run(
2022-08-31 18:26:07 +00:00
app="ovdashboard_api.main:app",
2022-08-28 23:59:57 +00:00
host="0.0.0.0",
port=8000,
reload=True,
)
2022-08-28 23:31:17 +00:00
if __name__ == "__main__":
main()