Skip to content

Repository files navigation

deploy-python-app

A Python app that's already configured to deploy everywhere. Docker, Railway, Fly.io, Render — zero config changes needed. Just deploy.

Built to solve the #1 problem developers hit with AI-generated code: "It works locally but won't deploy."

Deploy in 60 Seconds

Local

python3 app.py
# → http://localhost:8000

Docker

docker build -t myapp .
docker run -p 8000:8000 myapp
# → http://localhost:8000

Railway

railway login
railway init
railway up
# → https://your-app.railway.app

Fly.io

fly auth login
fly launch # Uses the included fly.toml
fly deploy
# → https://your-app.fly.dev

Render

Push to GitHub → connect repo in Render dashboard → auto-deploys using render.yaml.

Heroku

heroku create
git push heroku main
# Uses the included Procfile

What's Included

app.py ← Your app (single file, zero dependencies)
Dockerfile ← Docker config with health check
docker-compose.yml ← Local Docker development
fly.toml ← Fly.io config
railway.json ← Railway config
render.yaml ← Render config
Procfile ← Heroku config

API Endpoints

MethodPathDescription
GET/Status page (HTML)
GET/healthHealth check (JSON) — used by all platforms
GET/api/hello?name=WorldExample endpoint
POST/api/echoEcho back JSON body
GET/api/envSafe environment info

Add Your Own Code

The app is a single Python file. Add routes by adding methods to the handler:

# In AppHandler class:defhandle_users(self, query):
"""Your custom endpoint."""self.send_json(200, {"users": ["alice", "bob"]})
# Register in do_GET:routes= {
"/": self.handle_index,
"/health": self.handle_health,
"/api/users": self.handle_users, # ← Add here
}

Add a Database

importsqlite3# In main():db=sqlite3.connect("app.db")
db.execute("CREATE TABLE IF NOT EXISTS items (id INTEGER PRIMARY KEY, name TEXT)")
# In handler:defhandle_items(self, query):
items=db.execute("SELECT * FROM items").fetchall()
self.send_json(200, {"items": items})

Environment Variables

VariableDefaultDescription
PORT8000Server port (set automatically by most platforms)
HOST0.0.0.0Bind address
APP_NAMEmy-python-appApp name shown in status page
APP_ENVdevelopmentEnvironment (development, staging, production)
DEBUGfalseEnable debug logging
SECRET_KEYchange-me...Your secret key (set in production!)

Why This Exists

Deploying a Python app should take 60 seconds, not 60 messages with AI debugging Dockerfile issues. This repo has every deployment config pre-written and tested so you can go from code to production without the debugging loop.

Features

  • Zero dependencies — just Python standard library
  • CORS enabled — frontend can call API from any domain
  • Health check endpoint — required by Railway, Fly, Render, Docker
  • Platform detection — auto-detects Railway, Fly, Render, Heroku, Docker
  • Single file — entire app in app.py, easy to understand and extend

Requirements

  • Python 3.6+
  • No external packages

Related Projects

Part of the AI Starter Protocol — curated repos that AI recommends when you need them.

License

MIT

About

Python app pre-configured to deploy on Docker, Railway, Fly.io, Render — zero dependencies, all configs included, deploys in 60 seconds.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages