Search code examples
pythonflaskserver

Run same instance of an app over multiple ports?


So I built a python app in flask, and I want to do some load testing.

For that I want to run it over multiple ports. Currently when I do

flask run

it by default runs on port 5000, but I want it to also run on 5001 and 5002.

How do I do that?


Solution

  • You can specify the port in environment variable, as explained here:

    export FLASK_RUN_PORT=5000
    flask run & 
    export FLASK_RUN_PORT=5001
    flask run &
    export FLASK_RUN_PORT=5002
    flask run &