A profile,

By using the flask-script extension, you can pass in parameters from the command line when the Flask server is started. Instead of just passing in the app.run() method, for example we can tell the server which network interface to listen for connections from clients by using python script_flask.py runserver –host IP address. By default, the server only listens for connections that originate from the computer on which the server is located, known as localhost connections.

Second, the use of

First now install the flask-script extension:

pip install Flask-Script
Copy the code

In the program:

from flask import Flask
from flask_script import Manager

app = Flask(__name__)

Use Manager to manage app objects
manager = Manager(app)


@app.route('/')
def index(a):
    return 'index page'


if __name__ == '__main__':
    Run with the Manager object
    manager.run()
Copy the code

So we can start Flask’s server like Django:

python script_flask.py runserver
Copy the code

If you want to run on other IP and Port:

python demo.py runserver -h 0.0. 0. 0 -p 5000 -d    # -d indicates debug
Copy the code

You can also enter the shell environment:

python demo.py shell    Enter the interactive Python environment and automatically import the content in demo.py.
Copy the code

Welcome to follow my official account: