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

前端 未结 2 888
忘了有多久
忘了有多久 2020-12-15 07:20

I have one flask application script as given below :

from flask import Flask
app = Flask(__name__)

@app.route(\"/\")
def main(job_id):
         


        
相关标签:
2条回答
  • 2020-12-15 07:31

    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
    
    0 讨论(0)
  • 2020-12-15 07:48

    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

    0 讨论(0)
提交回复
热议问题