This repository has been archived by the owner on Dec 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add command line for running the server
- Loading branch information
1 parent
b397c9e
commit 3301de3
Showing
2 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |