ovdashboard/api/ovdashboard_api/main.py
2022-09-05 23:30:06 +02:00

44 lines
914 B
Python

#!/usr/bin/env python3
"""
Main script for `ovdashboard_api` module.
Creates the main `FastAPI` app.
"""
import uvicorn
from fastapi import FastAPI
from .settings import SETTINGS
from .routers import main_router
app = FastAPI(
title="OVDashboard API",
description="This API enables the `OVDashboard` service.",
contact={
"name": "Jörn-Michael Miehe",
"email": "jmm@yavook.de",
},
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)
def main() -> None:
"""
If the `main` script is run, `uvicorn` is used to run the app.
"""
uvicorn.run(
app="ovdashboard_api.main:app",
host="0.0.0.0",
port=8000,
reload=True,
)
if __name__ == "__main__":
main()