Skip to content
This repository has been archived by the owner on Dec 24, 2024. It is now read-only.

Commit

Permalink
feat: add command line for running the server
Browse files Browse the repository at this point in the history
  • Loading branch information
1995parham committed Mar 10, 2024
1 parent b397c9e commit 3301de3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
Main module to run the FastAPI application which is called by uvicorn.
"""

import rich
from fastapi import FastAPI

from app import config
from app.routers import users

settings = config.Settings()
print(settings.model_dump())
rich.print(f"configuration: {settings.model_dump()}")

app = FastAPI(debug=settings.http.debug)

Expand Down
24 changes: 24 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import typer
import uvicorn

app = typer.Typer()


@app.command()
def serve(port: int = 1378, debug: bool = False):
print(f"FastAPI101 is coming up 0.0.0.0:{port}")
uvicorn.run(
"app.main:app",
host="0.0.0.0",
port=port,
reload=debug,
workers=5,
backlog=1024,
log_level="debug" if debug else "info",
use_colors=True,
access_log=debug,
)


if __name__ == "__main__":
app()

0 comments on commit 3301de3

Please sign in to comment.