50 lines
1.1 KiB
Python
50 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
|
|
"""
|
|
Main script for `ovdashboard_api` module.
|
|
|
|
Creates the main `FastAPI` app.
|
|
"""
|
|
|
|
from fastapi import FastAPI
|
|
from uvicorn import run as uvicorn_run
|
|
|
|
from .dav_common import webdav_check
|
|
from .routers import main_router
|
|
from .settings import SETTINGS
|
|
|
|
app = FastAPI(
|
|
title="OVDashboard API",
|
|
description="This API enables the `OVDashboard` service.",
|
|
contact={
|
|
"name": "Jörn-Michael Miehe",
|
|
"email": "jmm@yavook.de",
|
|
},
|
|
license_info={
|
|
"name": "MIT License",
|
|
"url": "https://opensource.org/licenses/mit-license.php",
|
|
},
|
|
openapi_url=SETTINGS.openapi_url,
|
|
docs_url=SETTINGS.docs_url,
|
|
redoc_url=SETTINGS.redoc_url,
|
|
)
|
|
|
|
app.include_router(main_router)
|
|
|
|
|
|
def main() -> None:
|
|
"""
|
|
If the `main` script is run, `uvicorn` is used to run the app.
|
|
"""
|
|
|
|
if webdav_check():
|
|
uvicorn_run(
|
|
app="ovdashboard_api.main:app",
|
|
host="0.0.0.0",
|
|
port=8000,
|
|
reload=not SETTINGS.production_mode,
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|