How to Deploy a FastAPI App Fast
FastAPI has become the go-to framework for building Python APIs. It's fast, modern, and developer-friendly. This guide shows you how to deploy a FastAPI application in minutes, not hours.
Prerequisites
- A FastAPI application on GitHub
- A SnapDeploy account (free tier available)
The FastAPI Application
# main.py
from fastapi import FastAPI
app = FastAPI(title="My API")
@app.get("/")
def read_root():
return {"status": "healthy"}
@app.get("/items/{item_id}")
def read_item(item_id: int):
return {"item_id": item_id}
Deploy Fast
Seconds 0-15: Connect GitHub
Log into SnapDeploy, click "New Container", select your repository.
Seconds 15-30: Configure
Name your container. Port 8000 is auto-detected for FastAPI.
Seconds 30-45: Environment Variables
Add any secrets: DATABASE_URL, API_KEY, etc.
Seconds 45-60: Deploy
Click "Deploy". SnapDeploy automatically detects Python, installs dependencies, and starts uvicorn.
Smart Detection
SnapDeploy scans your codebase for:
- requirements.txt - Identifies Python project
- FastAPI import - Detects the framework
- App variable - Finds
app = FastAPI()
Adding a Database
- Go to "Add-ons" in SnapDeploy
- Click "Create Add-On" and select PostgreSQL
- Link to your container during deployment
Environment variables are automatically injected:
DATABASE_URL=postgresql://user:pass@host:5432/mydb
POSTGRES_HOST=internal-host
POSTGRES_PORT=5432
Automatic API Docs
FastAPI's built-in docs work automatically:
- Swagger UI: https://your-app.snapdeploy.app/docs
- ReDoc: https://your-app.snapdeploy.app/redoc
Ready to Deploy?
Get 100 free hours to deploy and test your applications. No credit card required.
Start Free Trial