#方式一
@app.route('/index.html',methods=['GET','POST'],endpoint='index')#endpoint是别名

def index():
return 'Index'
#方式二

def index():
return "Index"

self.add_url_rule(rule='/index.html', endpoint="index", view_func=index, methods=["GET","POST"]) #endpoint是别名
or
app.add_url_rule(rule='/index.html', endpoint="index", view_func=index, methods=["GET","POST"])
app.view_functions['index'] = index

添加路由关系的本质:将url和视图函数封装成一个Rule对象,添加到Flask的url_map字段中

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-07
  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
  • 2021-08-19
猜你喜欢
  • 2022-12-23
  • 2021-11-08
  • 2021-12-22
  • 2022-12-23
  • 2021-10-29
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案