# -*- coding: utf-8 -*-from flask import Flask, request, url_forapp = Flask(__name__)@app.route("/")def hello(): return "Hell2323o23 World!"@app.route('/user', methods=['POST']) #默认是get方式def hello_user(): return 'hello user'@app.route('/users/') #传递参数方式1 访问localhost:7999/users/10def user_id(id): return 'hello world'+id@app.route('/query_user', methods=['POST']) #传递参数方式2 访问localhost:7999/users?id=10def query_user(): id = request.args.get('id') return 'query_user:'+id@app.route('/query_url')def query_url(): return 'query_url:::'+url_for('query_user') #反倒上面query_user函数的URL#反向路由就是从视图函数反倒出URL地址if __name__ == "__main__": app.debug = True app.run( port=7999)