FlaskWeb开发:基于Python的Web应用开发实战.pdf
git clone https://github.com/miguelgrinberg/flasky.git
git checkout 2a
修改一下 代码:
代码:
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return 'Hello World!
'
if __name__ == '__main__':
app.run(host='0.0.0.0',port=8089)
http://192.168.99.215:8089/
log为:
(venv) [xxx@localhost flasky]$ python hello.py
* 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://0.0.0.0:8089/ (Press CTRL+C to quit)
192.168.99.219 - - [31/Jul/2019 15:54:26] "GET / HTTP/1.1" 200 -
192.168.99.219 - - [31/Jul/2019 15:54:29] "GET / HTTP/1.1" 200 -
192.168.99.219 - - [31/Jul/2019 15:54:36] "GET / HTTP/1.1" 200 -
192.168.99.219 - - [31/Jul/2019 15:54:36] "GET /favicon.ico HTTP/1.1" 404 -
192.168.99.219 - - [31/Jul/2019 15:54:51] "GET / HTTP/1.1" 200 -
192.168.99.219 - - [31/Jul/2019 15:54:51] "GET /favicon.ico HTTP/1.1" 404 -
有的端口可能不能用,换一个其他的端口
git reset --hard 取消 修改,回到 修改前的版本库的状态
git checkout 2a
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return 'Hello World!
'
@app.route('/user/')
def user(name):
return 'Hello, {}!
'.format(name)
if __name__ == '__main__':
app.run(host='0.0.0.0',port=8089)
hello
page22
flask run --host 0.0.0 --port 8089
source activate
flask run --help
git checkout 2a
export FLASK_APP=hello.py
git reset --hard
python hello.py runserver --host 0.0.0.0 --port 8089
如果你从GitHub 上克隆了这个应用的Git 仓库,那么可以执行git checkout
3b 检出应用的这个版本 。别忘了在你的虚拟环境中安装Flask-Bootstrap 包。
Bootstrap 官方文档(https://getbootstrap.com/docs/4.1/getting-started/introduction/)
是很好的学习资源,有很多可以直接复制粘贴的示例。
#### Post
page 37
page43
(稍后补充)