A lightweight, production-ready FastAPI server that you can clone, configure with your own IP & port, and expose to the internet.
- FastAPI with auto-generated docs (
/docs,/redoc) - Configurable host IP and port via
.envfile - Works on Linux, macOS, Windows
- One-command startup scripts
- Health check endpoint at
/health
git clone https://github.com/hackerlemonaru/FastAPI.git
cd FastAPIpip install -r requirements.txtcp .env.example .envEdit .env to set your IP and port:
HOST=0.0.0.0 # 0.0.0.0 = accept from all interfaces (recommended)
PORT=8000 # change this to any open port you want
WORKERS=1
LOG_LEVEL=infoTip: Use
HOST=0.0.0.0so the server accepts connections from any IP.
Then use your machine's public IP to access it from the internet.
Linux / macOS:
chmod +x start.sh
./start.shWindows:
start.batOr manually:
hypercorn main:app --bind 0.0.0.0:8000 --reload| Method | Path | Description |
|---|---|---|
| GET | / |
Hello World response |
| GET | /health |
Health check |
| GET | /info |
Server info (host/port) |
| GET | /docs |
Swagger UI |
| GET | /redoc |
ReDoc documentation |
To make your server accessible from the internet:
-
Open the port in firewall:
sudo ufw allow 8000/tcp sudo ufw reload
-
Find your public IP:
curl ifconfig.me
-
Access via browser or curl:
http://YOUR_PUBLIC_IP:8000 http://YOUR_PUBLIC_IP:8000/docs
-
Set up Port Forwarding in your router settings:
- External Port:
8000 - Internal IP: your local machine IP (e.g.
192.168.1.x) - Internal Port:
8000 - Protocol: TCP
- External Port:
-
Find your public IP at https://whatismyip.com
-
Access:
http://YOUR_PUBLIC_IP:8000
Works out of the box — just open the port in your cloud provider's security group / firewall rules and run the server with HOST=0.0.0.0.
FastAPI/
├── main.py # FastAPI application
├── requirements.txt # Python dependencies
├── .env.example # Config template (copy to .env)
├── .env # Your config (NOT committed to git)
├── start.sh # Linux/macOS startup script
├── start.bat # Windows startup script
├── railway.json # Railway.app deployment config
└── README.md # This file
Railway will automatically set PORT via environment variable — no manual config needed.
- FastAPI — Web framework
- Hypercorn — ASGI server (HTTP/1, HTTP/2, HTTP/3)
- python-dotenv — Environment variable management
- Python 3.8+