2022-08-28 23:59:57 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
"""
|
|
|
|
Main executable of `ovkiosk`.
|
|
|
|
|
|
|
|
Creates the main `FastAPI` app.
|
|
|
|
|
|
|
|
If run directly, uses `uvicorn` to run the app.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import uvicorn
|
|
|
|
from fastapi import FastAPI
|
2022-08-29 00:36:13 +00:00
|
|
|
from webdav3.client import Client
|
2022-08-28 23:59:57 +00:00
|
|
|
|
|
|
|
from .config import SETTINGS
|
|
|
|
from .routers import main_router
|
|
|
|
|
|
|
|
app = FastAPI(
|
|
|
|
title="OVKiosk API",
|
|
|
|
description="This API enables the `OVKiosk` service.",
|
|
|
|
contact={
|
|
|
|
"name": "Jörn-Michael Miehe",
|
|
|
|
"email": "40151420+ldericher@users.noreply.github.com",
|
|
|
|
},
|
|
|
|
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-29 00:36:13 +00:00
|
|
|
options = {
|
|
|
|
"webdav_hostname": SETTINGS.webdav_url,
|
|
|
|
"webdav_login": SETTINGS.dav_username,
|
|
|
|
"webdav_password": SETTINGS.dav_password,
|
|
|
|
}
|
|
|
|
client = Client(options)
|
|
|
|
print(client.list())
|
|
|
|
|
2022-08-28 23:59:57 +00:00
|
|
|
uvicorn.run(
|
|
|
|
app="ovkiosk.main:app",
|
|
|
|
host="0.0.0.0",
|
|
|
|
port=8000,
|
|
|
|
reload=True,
|
|
|
|
)
|
2022-08-28 23:31:17 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|