Python - How to run multiple flask apps from same client machine Python - How to run multiple flask apps from same client machine flask flask

Python - How to run multiple flask apps from same client machine


Flask development server by default listens on port 5000 so when you run a Flask app without port number it will run on 5000.

You can run a number of Flask app on the same machine but with the different port numbers. Let's say your scripts names are script1.py and script2.py:

$ export FLASK_APP=script1.py$ flask run --host 0.0.0.0 --port 5000

Open up a new terminal

$ export FLASK_APP=script2.py$ flask run --host 0.0.0.0 --port 5001


Did you clear cache memory before running second script. There are times when browser stored previos data on the port so it will display old data.

You can clear the cache memory and then run second script. then execute and see.I hope it will solved problem


I have very simple solution for this problem just add this below line in your code app.run(port=3000)

simply assume that your first application is working using 5000 port and you try to execute another flask app it may using the same port which is 5000 so that's why you may face these problem so just simply add this line of code in which you can change your port number to execute the application on another port.

example:

if __name__ == '__main__':    app.run(port=3000)

Note: instead of port 3000 you can enter any of your choice