{
  "manifest_version": "1",
  "slug": "flask",
  "title": "Flask",
  "headline": "Deploy a Flask app",
  "description": "Deploy Flask to a VM of its own: gunicorn under systemd, SQLite or PostgreSQL on a persistent disk, git pull deploys, and sign-in by exe.dev.",
  "category": "frameworks",
  "tags": [
    "flask",
    "python",
    "gunicorn",
    "nginx",
    "sqlite",
    "flask-sqlalchemy",
    "flask-migrate",
    "uv",
    "rq",
    "heroku alternative"
  ],
  "url": "https://exe.dev/deploy/flask",
  "markdown_url": "https://exe-staging.dev/deploy/flask.md",
  "upstream": {
    "website": "https://flask.palletsprojects.com",
    "source": "https://github.com/pallets/flask",
    "docs": "https://flask.palletsprojects.com/en/stable/deploying/",
    "license": "BSD-3-Clause"
  },
  "example_vm_name": "my-flask",
  "time": "10 minutes",
  "stack": [
    {
      "name": "Your Flask app",
      "detail": "Flask 3.1 on Python 3.14, installed by uv; one release per deploy",
      "data": "~/app"
    },
    {
      "name": "gunicorn",
      "detail": "`app.service`: gthread workers sized to the VM, on a Unix socket"
    },
    {
      "name": "nginx",
      "detail": "static files, and a buffer in front of gunicorn",
      "port": 8000
    },
    {
      "name": "SQLite",
      "detail": "Flask-SQLAlchemy and Flask-Migrate, WAL mode",
      "data": "~/data/app.db"
    },
    {
      "name": "deploy",
      "detail": "pulls from GitHub, builds, migrates, restarts, rolls back on failure",
      "data": "~/src"
    },
    {
      "name": "Nightly backups",
      "detail": "database, data, settings, and code; keeps a week",
      "data": "~/backups"
    }
  ],
  "access": [
    {
      "url": "https://my-flask.exe.xyz/",
      "who": "private",
      "what": "your app, signed in with exe.dev, until you make it public"
    },
    {
      "url": "my-flask.exe.xyz:src",
      "who": "private",
      "what": "the code on the VM, if it isn't on GitHub"
    }
  ],
  "inputs": [
    {
      "name": "REPO",
      "description": "the GitHub repository to deploy, as owner/name or a URL, or `new` to start a fresh Flask app"
    }
  ],
  "delivers": [
    "Your Flask app, or a new Flask 3.1 app with Flask-SQLAlchemy and Flask-Migrate, served by gunicorn behind nginx on port 8000, under systemd and enabled to start after a reboot.",
    "`deploy` (in /usr/local/bin) pulls `~/src` from its origin, builds the commit in a new `~/releases` directory, runs `flask db upgrade`, switches `~/app` to it, restarts and checks it answers; any failure leaves the running release up.",
    "Settings for exe.dev's proxy outside the repository, in `~/app.env` and `~/app-settings`, with a generated secret key, ProxyFix for the forwarded headers, and gunicorn workers sized to the VM.",
    "SQLite in WAL mode at `~/data/app.db` (or the app's own database), with Flask's static folder served by nginx.",
    "The owner's exe.dev email in `FLASK_ADMIN_EMAILS`, and a new app that signs visitors in from the `X-ExeDev-Email` header.",
    "Nightly backups in `~/backups`, with a first one taken and checked."
  ],
  "owner_runs_after": [
    "ssh my-flask.exe.xyz deploy                 # after each git push to GitHub",
    "git clone my-flask.exe.xyz:src my-flask     # if you started a new app and it isn't on GitHub yet"
  ],
  "deployable": true,
  "deploy": {
    "new_vm_url": "https://exe-staging.dev/new?prompt=REPO%3D%3Cfill-this-in%3E%0A%0ASet%20up%20Flask%20on%20this%20VM%20by%20following%20the%20exe.dev%20recipe%20at%20https%3A%2F%2Fexe-staging.dev%2Fdeploy%2Fflask.md%20from%20top%20to%20bottom.%0A%0AThe%20values%20at%20the%20top%20of%20this%20message%20are%20mine%3A%0A-%20REPO%3A%20the%20GitHub%20repository%20to%20deploy%2C%20as%20owner%2Fname%20or%20a%20URL%2C%20or%20%60new%60%20to%20start%20a%20fresh%20Flask%20app%0AAsk%20me%20for%20any%20that%20still%20say%20%3Cfill-this-in%3E%20before%20you%20need%20them.%0A%0AThe%20recipe%27s%20example%20VM%20name%20is%20my-flask.%20This%20VM%27s%20name%20is%20the%20output%20of%20%60hostname%60%3A%20use%20it%20wherever%20the%20recipe%20writes%20my-flask.%20Skip%20the%20step%20that%20creates%20the%20VM%3B%20you%20are%20on%20it.%0A%0AYou%20are%20done%20when%20all%20of%20these%20are%20true.%20Check%20each%20one%20yourself%3A%0A-%20Your%20Flask%20app%2C%20or%20a%20new%20Flask%203.1%20app%20with%20Flask-SQLAlchemy%20and%20Flask-Migrate%2C%20served%20by%20gunicorn%20behind%20nginx%20on%20port%208000%2C%20under%20systemd%20and%20enabled%20to%20start%20after%20a%20reboot.%0A-%20%60deploy%60%20%28in%20%2Fusr%2Flocal%2Fbin%29%20pulls%20%60~%2Fsrc%60%20from%20its%20origin%2C%20builds%20the%20commit%20in%20a%20new%20%60~%2Freleases%60%20directory%2C%20runs%20%60flask%20db%20upgrade%60%2C%20switches%20%60~%2Fapp%60%20to%20it%2C%20restarts%20and%20checks%20it%20answers%3B%20any%20failure%20leaves%20the%20running%20release%20up.%0A-%20Settings%20for%20exe.dev%27s%20proxy%20outside%20the%20repository%2C%20in%20%60~%2Fapp.env%60%20and%20%60~%2Fapp-settings%60%2C%20with%20a%20generated%20secret%20key%2C%20ProxyFix%20for%20the%20forwarded%20headers%2C%20and%20gunicorn%20workers%20sized%20to%20the%20VM.%0A-%20SQLite%20in%20WAL%20mode%20at%20%60~%2Fdata%2Fapp.db%60%20%28or%20the%20app%27s%20own%20database%29%2C%20with%20Flask%27s%20static%20folder%20served%20by%20nginx.%0A-%20The%20owner%27s%20exe.dev%20email%20in%20%60FLASK_ADMIN_EMAILS%60%2C%20and%20a%20new%20app%20that%20signs%20visitors%20in%20from%20the%20%60X-ExeDev-Email%60%20header.%0A-%20Nightly%20backups%20in%20%60~%2Fbackups%60%2C%20with%20a%20first%20one%20taken%20and%20checked.%0A%0ARead%20the%20whole%20recipe%2C%20including%20the%20closed%20details%2C%20and%20follow%20%22Set%20it%0Aup%20by%20hand%22%20in%20order%2C%20skipping%20%22Create%20the%20VM%22%3B%20the%20walkthrough%20above%20it%0Ais%20for%20the%20owner.%20REPO%3Dnew%20takes%20%22Start%20a%20new%20app%22%3B%20anything%20else%20takes%0A%22Bring%20your%20repository%22.%20If%20cloning%20from%20GitHub%20fails%2C%20the%20repository%20is%0Aprivate%3A%20give%20the%20owner%20the%20%60ssh%20exe.dev%20integrations%20add%20github%60%20command%0Afrom%20that%20step%2C%20with%20this%20VM%27s%20name%20and%20the%20repository%2C%20wait%20for%20them%2C%0Aand%20clone%20from%20github.int.exe.xyz.%0ANever%20overwrite%20an%20existing%20~%2Fapp.env.%20Don%27t%20commit%20to%20the%20owner%27s%0Arepository%20or%20push%20to%20its%20origin.%20If%20their%20app%20doesn%27t%20fit%20%28no%20factory%0Aor%20%60app%60%20object%20Flask%20can%20find%2C%20settings%20read%20from%20other%20variable%20names%2C%0Aa%20different%20database%29%2C%20set%20FLASK_APP%20and%20~%2Fapp.env%20to%20fit%20it%20and%20tell%0Athe%20owner%20what%20you%20changed%20and%20what%20their%20code%20should%20read.%0ALeave%20the%20VM%20private%20and%20don%27t%20reboot%3A%20check%20that%20app.service%2C%20nginx%20and%0Aapp-backup.timer%20are%20enabled%20instead.%20Skip%20the%20later%20Restore%20and%20Update%0Ainstructions%3B%20the%20restore%20check%20in%20setup%20uses%20a%20scratch%20copy%20only.%20Don%27t%0Aturn%20on%20the%20optional%20timers%2C%20worker%2C%20or%20LLM%20endpoint%20unless%20asked.%0AGive%20the%20owner%20https%3A%2F%2F%3Cvm%3E.exe.xyz%2F%20and%2C%20of%20the%20two%20commands%20at%20the%0Aend%2C%20the%20one%20that%20fits%20REPO.%0A%0AFinish%20with%20the%20URLs%20I%20should%20open%20and%20these%20commands%2C%20which%20only%20I%20can%20run%2C%20from%20my%20own%20computer%20%28with%20this%20VM%27s%20name%20in%20them%29%3A%0A%20%20ssh%20my-flask.exe.xyz%20deploy%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%20after%20each%20git%20push%20to%20GitHub%0A%20%20git%20clone%20my-flask.exe.xyz%3Asrc%20my-flask%20%20%20%20%20%23%20if%20you%20started%20a%20new%20app%20and%20it%20isn%27t%20on%20GitHub%20yet%0A",
    "terminal": "curl -fsSL https://exe-staging.dev/deploy/flask/prompt.txt | ssh exe.dev new --prompt=/dev/stdin",
    "prompt": "REPO=\u003cfill-this-in\u003e\n\nSet up Flask on this VM by following the exe.dev recipe at https://exe-staging.dev/deploy/flask.md from top to bottom.\n\nThe values at the top of this message are mine:\n- REPO: the GitHub repository to deploy, as owner/name or a URL, or `new` to start a fresh Flask app\nAsk me for any that still say \u003cfill-this-in\u003e before you need them.\n\nThe recipe's example VM name is my-flask. This VM's name is the output of `hostname`: use it wherever the recipe writes my-flask. Skip the step that creates the VM; you are on it.\n\nYou are done when all of these are true. Check each one yourself:\n- Your Flask app, or a new Flask 3.1 app with Flask-SQLAlchemy and Flask-Migrate, served by gunicorn behind nginx on port 8000, under systemd and enabled to start after a reboot.\n- `deploy` (in /usr/local/bin) pulls `~/src` from its origin, builds the commit in a new `~/releases` directory, runs `flask db upgrade`, switches `~/app` to it, restarts and checks it answers; any failure leaves the running release up.\n- Settings for exe.dev's proxy outside the repository, in `~/app.env` and `~/app-settings`, with a generated secret key, ProxyFix for the forwarded headers, and gunicorn workers sized to the VM.\n- SQLite in WAL mode at `~/data/app.db` (or the app's own database), with Flask's static folder served by nginx.\n- The owner's exe.dev email in `FLASK_ADMIN_EMAILS`, and a new app that signs visitors in from the `X-ExeDev-Email` header.\n- Nightly backups in `~/backups`, with a first one taken and checked.\n\nRead the whole recipe, including the closed details, and follow \"Set it\nup by hand\" in order, skipping \"Create the VM\"; the walkthrough above it\nis for the owner. REPO=new takes \"Start a new app\"; anything else takes\n\"Bring your repository\". If cloning from GitHub fails, the repository is\nprivate: give the owner the `ssh exe.dev integrations add github` command\nfrom that step, with this VM's name and the repository, wait for them,\nand clone from github.int.exe.xyz.\nNever overwrite an existing ~/app.env. Don't commit to the owner's\nrepository or push to its origin. If their app doesn't fit (no factory\nor `app` object Flask can find, settings read from other variable names,\na different database), set FLASK_APP and ~/app.env to fit it and tell\nthe owner what you changed and what their code should read.\nLeave the VM private and don't reboot: check that app.service, nginx and\napp-backup.timer are enabled instead. Skip the later Restore and Update\ninstructions; the restore check in setup uses a scratch copy only. Don't\nturn on the optional timers, worker, or LLM endpoint unless asked.\nGive the owner https://\u003cvm\u003e.exe.xyz/ and, of the two commands at the\nend, the one that fits REPO.\n\nFinish with the URLs I should open and these commands, which only I can run, from my own computer (with this VM's name in them):\n  ssh my-flask.exe.xyz deploy                 # after each git push to GitHub\n  git clone my-flask.exe.xyz:src my-flask     # if you started a new app and it isn't on GitHub yet\n",
    "prompt_url": "https://exe-staging.dev/deploy/flask/prompt.txt"
  },
  "updated": "2026-11-16",
  "verified": "2026-11-16",
  "related": [
    "django",
    "fastapi",
    "postgres",
    "redis",
    "migrate-heroku",
    "agent-secrets"
  ],
  "alternatives": [
    "Heroku",
    "Render",
    "Railway",
    "PythonAnywhere"
  ]
}
