diff --git a/node/app_api.py b/node/app_api.py index ee14ecd..4f8b1e1 100644 --- a/node/app_api.py +++ b/node/app_api.py @@ -4,6 +4,7 @@ import os from contextlib import asynccontextmanager +import uvicorn from fastapi import FastAPI from fastapi.exception_handlers import http_exception_handler, request_validation_exception_handler from fastapi.exceptions import HTTPException, RequestValidationError @@ -46,7 +47,7 @@ def _create_app() -> FastAPI: title="Wigglecam Node API", description="API may change any time.", version=__version__, - contact={"name": "mgineer85", "url": "https://github.com/photobooth-app/photobooth-app", "email": "me@mgineer85.de"}, + contact={"name": "mgineer85", "url": "https://github.com/photobooth-app/wigglecam", "email": "me@mgineer85.de"}, docs_url="/api/doc", redoc_url=None, openapi_url="/api/openapi.json", @@ -72,3 +73,19 @@ async def validation_exception_handler(request, exc): app = _create_app() + + +def main(): + # to allow api is runnable via project.scripts shortcut + # ref: https://stackoverflow.com/a/70393344 + uvicorn.run( + app, + host="0.0.0.0", + port=8000, + reload=False, + log_level="debug", + ) + + +if __name__ == "__main__": + main() diff --git a/pyproject.toml b/pyproject.toml index 8a4a840..759bed6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,8 +53,7 @@ documentation = "https://github.com/mgineer85/photobooth-wigglecam" [project.scripts] wigglecam_minimal = "node.app_minimal:main" -# wigglecam_uvicorn = "uvicorn node.__main__:app --host=0.0.0.0 --port=8000 --log-level=debug" -# wigglify = "wigglify.cli:main" +wigglecam_api = "node.app_api:main" [tool.pdm] version = { source = "file", path = "node/__version__.py" }