Flask基础

来自linux中国网wiki
Evan讨论 | 贡献2021年6月23日 (三) 02:22的版本 (创建页面,内容为“ =install = <pre> mkdir myproject $ cd myproject $ python3 -m venv venv . venv/bin/activate $ pip install Flask vi hello.py from flask import Flask app = Fl…”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳到导航 跳到搜索


install


mkdir myproject
$ cd myproject
$ python3 -m venv venv

. venv/bin/activate

$ pip install Flask


vi hello.py

from flask import Flask

app = Flask(__name__)

@app.route("/")
def hello_world():
    return "<p>Hello, World!</p>"

flask  run 
 * Serving Flask app 'hello' (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

Now head over to http://127.0.0.1:5000/, and you should see your hello world greeting.

see also

flask quickstart