Python FLASK 學(xué)習(xí)筆記(一)
通過(guò)pip install?flask? ?安裝?flask
創(chuàng)建一個(gè)hello.py文件

在終端或者cmd輸入
????????????????set FLASK_APP=hello.py
????????????????flask run

返回???
?????* Serving Flask app "hello.py"
?????* 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)
在瀏覽器打開(kāi)http://127.0.0.1:5000/

return 可以返回字符串或者字典

route()
?裝飾器來(lái)把函數(shù)綁定到 URL


工廠(chǎng)模式?https://flask.palletsprojects.com/en/1.1.x/tutorial/factory/
在當(dāng)前文件夾創(chuàng)建文件?flaskr/__init__.py

在終端執(zhí)行
set FLASK_APP=flaskr
set FLASK_ENV=development
flask run

在工廠(chǎng)模式下, 修改?保存__init__?不需要重新執(zhí)行flask run?
標(biāo)簽: