The short answer
To deploy a Flask app for free, give your coding agent the sentence below. Antideploy finds Flask in your requirements, finds the file that creates your app, and starts it. Add gunicorn to requirements.txt so Antideploy runs it with gunicorn. Without it, Antideploy falls back to Flask's built-in server, which works but is meant for development, not real traffic.
Say this to your coding agent
Set this project up to deploy on Antideploy. Fetch https://antideploy.com/agent.md and follow it.
What Antideploy detects
-
Flask. Detected from
flaskinrequirements.txtorpyproject.toml. -
The start command. With
gunicorn,waitressoruwsgiin your requirements:gunicorn module:app --bind 0.0.0.0:$PORT. Without one:python -m flask --app module run --host 0.0.0.0 --port $PORT, and a warning. -
The module. The file that contains
app = Flask(. If none is found, it usesapp. -
The port. It starts the app with
PORTset. -
The Python version. From
.python-version,runtime.txtorrequires-pythoninpyproject.toml.
What your project needs
flask
gunicorn
psycopg[binary]
import os
import psycopg
from flask import Flask
app = Flask(__name__)
@app.get("/health")
def health():
return "ok"
# Do not call app.run() here. The start command runs the app.
You do not need to call app.run() or choose a host and port in code. The start command passes 0.0.0.0 and PORT. If you do call app.run() for local use, keep it under if __name__ == "__main__":.
Step by step
-
Add gunicorn
Add
gunicorntorequirements.txt. It is the production server for Flask. -
Paste the sentence and approve one link
Your agent creates the app and, if your code uses Postgres, the database. It writes the connection details into your
.envwithout printing them. -
Deploy and open the link
Antideploy installs your requirements, starts the app and checks that it answers. Your agent tells you the address.
Common problems
-
The app never starts listening. A
gunicorncommand with the wrong module name, or a crash on startup. The deploy shows what the app printed before it exited. See never started listening. -
No module named. A package your code imports is not in
requirements.txt. See ModuleNotFoundError. -
A package fails to compile. See Failed building wheel.
-
Uploads or a SQLite file disappear. The disk is replaced on every deploy. Use a bucket and Postgres.