diff --git a/api/.vscode/launch.json b/api/.vscode/launch.json index 8a57e6e..ff096b8 100644 --- a/api/.vscode/launch.json +++ b/api/.vscode/launch.json @@ -8,7 +8,7 @@ "name": "Main Module", "type": "python", "request": "launch", - "module": "ovdashboard_api.main", + "module": "ovdashboard_api", "justMyCode": true } ] diff --git a/api/ovdashboard_api/__init__.py b/api/ovdashboard_api/__init__.py index 038ce7a..fcdec95 100644 --- a/api/ovdashboard_api/__init__.py +++ b/api/ovdashboard_api/__init__.py @@ -9,8 +9,11 @@ from logging.config import dictConfig from pydantic import BaseModel +from .app import app from .settings import SETTINGS +__all__ = ["app"] + class LogConfig(BaseModel): """ diff --git a/api/ovdashboard_api/__main__.py b/api/ovdashboard_api/__main__.py new file mode 100644 index 0000000..e983129 --- /dev/null +++ b/api/ovdashboard_api/__main__.py @@ -0,0 +1,21 @@ +from uvicorn import run as uvicorn_run + +from .dav_common import webdav_check + + +def main() -> None: + """ + If the `main` script is run, `uvicorn` is used to run the app. + """ + + if webdav_check(): + uvicorn_run( + app="ovdashboard_api:app", + host="0.0.0.0", + port=8000, + reload=True, + ) + + +if __name__ == "__main__": + main() diff --git a/api/ovdashboard_api/main.py b/api/ovdashboard_api/app.py similarity index 75% rename from api/ovdashboard_api/main.py rename to api/ovdashboard_api/app.py index bdb201b..41c7a11 100644 --- a/api/ovdashboard_api/main.py +++ b/api/ovdashboard_api/app.py @@ -9,9 +9,7 @@ Creates the main `FastAPI` app. from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from fastapi.staticfiles import StaticFiles -from uvicorn import run as uvicorn_run -from .dav_common import webdav_check from .routers import main_router from .settings import SETTINGS @@ -56,21 +54,3 @@ else: allow_headers=["*"], expose_headers=["*"], ) - - -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=True, - ) - - -if __name__ == "__main__": - main()