move main function, launch module directly
This commit is contained in:
parent
bcc833d3a6
commit
fbf6c550d2
4 changed files with 25 additions and 21 deletions
2
api/.vscode/launch.json
vendored
2
api/.vscode/launch.json
vendored
|
@ -8,7 +8,7 @@
|
||||||
"name": "Main Module",
|
"name": "Main Module",
|
||||||
"type": "python",
|
"type": "python",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"module": "ovdashboard_api.main",
|
"module": "ovdashboard_api",
|
||||||
"justMyCode": true
|
"justMyCode": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -9,8 +9,11 @@ from logging.config import dictConfig
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
from .app import app
|
||||||
from .settings import SETTINGS
|
from .settings import SETTINGS
|
||||||
|
|
||||||
|
__all__ = ["app"]
|
||||||
|
|
||||||
|
|
||||||
class LogConfig(BaseModel):
|
class LogConfig(BaseModel):
|
||||||
"""
|
"""
|
||||||
|
|
21
api/ovdashboard_api/__main__.py
Normal file
21
api/ovdashboard_api/__main__.py
Normal file
|
@ -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()
|
|
@ -9,9 +9,7 @@ Creates the main `FastAPI` app.
|
||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
from uvicorn import run as uvicorn_run
|
|
||||||
|
|
||||||
from .dav_common import webdav_check
|
|
||||||
from .routers import main_router
|
from .routers import main_router
|
||||||
from .settings import SETTINGS
|
from .settings import SETTINGS
|
||||||
|
|
||||||
|
@ -56,21 +54,3 @@ else:
|
||||||
allow_headers=["*"],
|
allow_headers=["*"],
|
||||||
expose_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()
|
|
Loading…
Reference in a new issue