Run a Flask Project on Replit With Your Own Start Command

A Replit workspace can run a project built with its existing Python framework. For an imported Flask project, make the app module and listen port explicit so the preview starts the same process you can run from Shell.

Worked example

A Flask workspace health probe

from flask import Flask

app = Flask(__name__)

@app.get("/health")
def health():
    return {"ok": True}

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=3000)

Steps

  1. Import your own repository into Replit or create a Python project. Put Flask in the project's dependencies and install them with its existing package manager.
  2. Save the sample as app.py and use python3 app.py as the workspace run command. If .replit defines a port mapping, make sure localPort is 3000 in this example.
  3. Start the workspace app and check /health in Replit's Preview. In Shell, curl http://127.0.0.1:3000/health to distinguish a server startup problem from a preview mapping problem.

What to check

  • If the local endpoint works but Preview fails, inspect the selected port and Replit's port mapping. If both fail, read the startup error and confirm Flask is installed.
  • The Flask development server is for this workspace check. Configure a production WSGI server and deployment run command before publishing a real Flask application.

See the Replit tool profile

References