标签:lse int detail 生成 efault views one use poi
# app.add_url_rule("/", view_func=UserView.as_view(name="user"))
# rule, URL规则
# view_func, 视图函数名称
# 为函数提供参数
# endpoint = None, 名称,用于反向生成URL,即: url_for('名称')
# methods = None, 允许的请求方式,如:["GET", "POST"]
# defaults = None, 默认值, 当URL中无参数,函数需要参数时,使用defaults = {'k': 'v'}
# #对URL最后的 / 符号是否严格要求
# strict_slashes = None
# '''
# @app.route('/index', strict_slashes=False)
# #访问http://www.xx.com/index/ 或http://www.xx.com/index均可
# @app.route('/index', strict_slashes=True)
# #仅访问http://www.xx.com/index
# '''
# #重定向到指定地址
# redirect_to = None,
from flask import Flask,redirect,render_template,jsonify,views
app=Flask(__name__)
#strict_slashes,该参数是用来设置,我们的路由是否为严格模式,False是非严格模式,True严格,默认是严格
@app.route("/index",strict_slashes=True,redirect_to ="/login")
def index():
return "ok"
@app.route("/login")
def login():
return "sb"
@app.route("/detail/<int:nid>")
def detail(nid):
print(nid)
return "ok"
if __name__ == '__main__':
app.run()
标签:lse int detail 生成 efault views one use poi
原文地址:https://www.cnblogs.com/suren-apan/p/11966143.html