Flask安装
pip install Flask
项目配置
debug模式 Host 端口号
from flask import Flask, request
app = Flask(__name__)
# http://192.168.31.118:5001/
@app.route('/')
def hello_world(): # put application's code here
return 'Hello World12223!'
# http://192.168.31.118:5001/my
@app.route('/my')
def my():
return 'My name is Douge'
# http://192.168.31.118:5001/book/list 你获取的是1
# http://192.168.31.118:5001/book/list?page=2 你获取的是2
@app.route('/book/list')
def book_detail():
page = request.args.get('page',default=1,type=int)
return '你获取的是{}'.format(page)
if __name__ == '__main__':
app.run()