Skip to content

Commit

Permalink
simplify running app
Browse files Browse the repository at this point in the history
  • Loading branch information
mgineer85 committed Oct 25, 2024
1 parent 5e1a64b commit 78611f8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
19 changes: 18 additions & 1 deletion node/app_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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": "[email protected]"},
contact={"name": "mgineer85", "url": "https://github.com/photobooth-app/wigglecam", "email": "[email protected]"},
docs_url="/api/doc",
redoc_url=None,
openapi_url="/api/openapi.json",
Expand All @@ -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()
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down

0 comments on commit 78611f8

Please sign in to comment.