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

前端 未结 2 892
忘了有多久
忘了有多久 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
    

提交回复
热议问题