-
-
Notifications
You must be signed in to change notification settings - Fork 538
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#469 improved fastapi example and docs
We should always use workers == 1
- Loading branch information
Showing
4 changed files
with
25 additions
and
5 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from fastapi import FastAPI | ||
|
||
from nicegui import ui | ||
|
||
|
||
|
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 |
---|---|---|
@@ -1,4 +1,23 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Start the FastAPI app | ||
uvicorn main:app --reload | ||
if [ "$#" -ne 1 ]; then | ||
echo "Usage: $0 <prod|dev>" | ||
exit 1 | ||
fi | ||
|
||
# use path of this demo as working directory; enables starting this script from anywhere | ||
cd "$(dirname "$0")" | ||
|
||
if [ "$1" = "prod" ]; then | ||
echo "Starting Uvicorn server in production mode..." | ||
# we also use a single worker in production mode so socket.io connections are always handled by the same worker | ||
uvicorn main:app --workers 1 --log-level info --port 80 | ||
elif [ "$1" = "dev" ]; then | ||
echo "Starting Uvicorn server in development mode..." | ||
# reload implies workers = 1 | ||
uvicorn main:app --reload --log-level debug --port 8080 | ||
else | ||
echo "Invalid parameter. Use 'prod' or 'dev'." | ||
exit 1 | ||
fi | ||
|
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