-
Notifications
You must be signed in to change notification settings - Fork 0
programming-maestro/SampleFastAPI
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
Library Installation:
pip install fastapi uvicorn[standard] aiofiles
Validate Libraries:
pip show fastapi
cpip show uvicorn
pip show aiofiles
or
pip list
Run Locally (Validate your script functionality):
Create a virtualenv and install ():
cd C:\Users\win11-pc\PycharmProjects\FastAPISample
python -m venv .venv
source .venv/bin/activate # on PowerShell: .\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
#uvicorn main:app --reload
Start Server
#uvicorn main:app --reload
uvicorn main:app --host 127.0.0.1 --port 8000
uvicorn main:app --host 0.0.0.0 --port 8000 --reload
note: The --reload flag tells Uvicorn to automatically restart whenever you edit your Python files.
This is safe for local development (not for production).
Get Request:
Hit from browser: http://127.0.0.1:8000/log
cmd: curl http://127.0.0.1:8000/log
Docker Execution:
powershell:
Installing ubuntu [if not already installed]
powershell (admin): wsl --install
wsl --list --verbose
If you see no Linux distributions, install Ubuntu from the Microsoft Store
Make sure Docker is set to use WSL 2 in Docker Desktop settings.
Enable Docker integration
Open Docker Desktop → Settings → Resources → WSL Integration.
Enable your newly installed Ubuntu distro.
Click Apply & Restart.
(pycharm terminal or cmd or ) powershell project folder:
# build
docker build -t timestamp-logger:latest .
# create a local host folder to persist logs
mkdir -p ./data
# run, mounting host ./data to container /data
docker run -d --name ts-logger -v "$(pwd)/data:/data" -p 8000:8000 timestamp-logger:latest
About
Python Fast API + Docker + DockerCompose + Kubernetes (Local) + AutoScaling (Pods)
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published