from flask import Flask
app = Flask(__name__)
@app.route('/hi')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
app.run(debug=True,host='0.0.0.0', port=8080)
运行输出:
FLASK_APP = app.py
FLASK_ENV = development
FLASK_DEBUG = 1
In folder D:/python/lean/site1
D:\python\lean\site1\venv\Scripts\python.exe -m flask run --host=0.0.0.0
* Serving Flask app "app.py" (lazy loading)
* Environment: development
* Debug mode: on
* Restarting with stat
* Debugger is active!
* Debugger PIN: 101-980-123
* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
192.168.3.2 - - [05/Feb/2020 09:27:15] "GET / HTTP/1.1" 200 -
192.168.3.2 - - [05/Feb/2020 09:27:15] "GET /favicon.ico HTTP/1.1" 404 -
In other environments, set ip and port access, the last one set up directly in the host and port just fine. But in pycharm2018, pycharm2019 are not. Need to go
run-Edit-Configuration, find Additinal options bar: manual written --host = xxxx --port = xxxx.
Good pit ....