Skip to content
← Blog

How to deploy a Python app built with Claude Code

Deploy a FastAPI, Flask, or Django app Claude Code built: a Dockerfile that binds 0.0.0.0 on $PORT, migrations that run before traffic moves, Django's production settings, and a floo.app.toml with Postgres and sign-in.

floo team

TL;DR

To deploy a Python app built with Claude Code, paste Read https://getfloo.com/docs/introduction.md and deploy this app to floo. into Claude Code. It writes a Dockerfile and floo.app.toml, then runs floo deploy. The first deploy works when the server binds 0.0.0.0 on $PORT, migrations run as migrate_command, and, for Django, the proxy settings and secret key are in place.

  • Same steps for FastAPI, Flask, and Django.
  • Postgres and sign-in are a few lines of floo.app.toml.
  • Every push to main deploys to the dev URL.

Claude Code writes a lot of Python: FastAPI for APIs and agents, Flask for small tools, Django when the app needs an admin and real models. floo builds the Dockerfile in your repository and runs it, so all three deploy the same way.

1. Ask Claude Code to deploy it

In the project folder:

Read https://getfloo.com/docs/introduction.md and deploy this app to floo.

Claude Code installs the CLI, writes the files below, commits, and runs floo deploy. You approve one sign-in in the browser. It waits until the URL is live and fixes the build if it fails.

2. Bind to all interfaces on $PORT

This is the one fix every Python app needs. floo sets PORT and only reaches processes bound to 0.0.0.0. Use the shell form of CMD so $PORT expands:

FROM python:3.13-slim
ENV PYTHONUNBUFFERED=1
WORKDIR /app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD ["sh", "-c", "uvicorn app.main:app --host 0.0.0.0 --port $PORT"]

For Flask or Django, the last line runs gunicorn instead, such as gunicorn mysite.wsgi:application --bind 0.0.0.0:$PORT.

Two more details: floo's edge answers /healthz itself, so name your health route /health. And the edge ends TLS, so build absolute URLs from X-Forwarded-Proto, not the request's own scheme.

3. Add what the app needs

[app]
name = "my-api"
access_mode = "accounts"

[services.web]
type = "web"
path = "."
port = 8000
ingress = "public"
dev_command = "uvicorn app.main:app --reload --port 8000"
migrate_command = "alembic upgrade head"

[managed.default]
type = "postgres"
  • [managed.default] gives the app Postgres and a DATABASE_URL. Dev and prod have separate databases. For async SQLAlchemy, switch the URL's driver to asyncpg and keep TLS on.
  • migrate_command runs with the new image before traffic moves. A failed migration stops the deploy. Use python manage.py migrate --noinput for Django.
  • access_mode = "accounts" makes it invite-only. Handlers read the person from the X-Floo-User-Email header, with no login code.

4. Django's extra settings

Django checks hosts and HTTPS, and floo's edge sits in front of it, so settings.py needs:

import os

ALLOWED_HOSTS = [".getfloo.app", *filter(None, os.environ.get("DJANGO_ALLOWED_HOSTS", "").split(","))]
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
USE_X_FORWARDED_HOST = True

Add WhiteNoise for static files and run collectstatic in the Dockerfile. Runtime secrets are not available during the build, so give that one step a throwaway key and database:

RUN DJANGO_SECRET_KEY=collectstatic-only DATABASE_URL=sqlite:///:memory: python manage.py collectstatic --noinput

The real secret key goes in as a write-only secret once the app exists:

python -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())' \
  | floo env set DJANGO_SECRET_KEY --stdin --secret --app my-django-app
floo deploy --rebuild --app my-django-app

If the settings refuse to boot without a key, which they should, the very first deploy fails at boot. That is expected: set the key and rebuild.

5. Keep shipping

Every push to main deploys to the dev URL. floo dev --app my-api runs dev_command on your machine with the dev database's credentials. floo logs --app my-api shows what the server printed.

The full guides are FastAPI, Flask, and Django. For Next.js, see how to deploy a Next.js app built with Claude Code. Before Claude changes the schema of a live app, read how agents should test database migrations.

Frequently asked questions

How do I deploy a Python app that Claude Code built?

In the project folder, ask Claude Code to read https://getfloo.com/docs/introduction.md and deploy the app to floo. It writes a Dockerfile and floo.app.toml, runs floo deploy, and gives you the URL. It works the same for FastAPI, Flask, and Django.

Why does my deployed FastAPI or Flask app never answer?

The server is listening on 127.0.0.1 or a fixed port. Start it with --host 0.0.0.0 --port $PORT in a shell-form CMD so $PORT expands. floo sets PORT and only reaches processes bound to all interfaces.

What does a Django app need to run on floo?

ALLOWED_HOSTS that includes .getfloo.app, SECURE_PROXY_SSL_HEADER and USE_X_FORWARDED_HOST because TLS ends at floo's edge, WhiteNoise with collectstatic in the Dockerfile, migrate as the migrate_command, and DJANGO_SECRET_KEY set as a secret with floo env set.

Get your app live.

read https://getfloo.com/agents.md and set me up on floo

Get an API key
Usage-based pricing. See plans →