Flask 框架介绍
介绍
安装
pip install flask
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
# if __name__ == '__main__':
# app.run()
$ gunicorn main:app
[8267] [INFO] Starting gunicorn 19.10.0
[8267] [INFO] Listening at: http://127.0.0.1:8000 (8267)
[8267] [INFO] Using worker: sync
[8272] [INFO] Booting worker with pid: 8272
$ curl http://127.0.0.1:8000
Hello World!
其他
F&Q
RuntimeError: Working outside of application context
// app = Flask(__name__)
with app.app_context():
...