码迷,mamicode.com
首页 > 其他好文 > 详细

flask 简记

时间:2019-05-29 00:07:35      阅读:109      评论:0      收藏:0      [点我收藏+]

标签:请求   _id   eth   %s   允许   请求方式   int   其他   col   

路由

路由默认请求方式为 GET,如需增加其他请求方式,使用 methods 参数:

# 增加了 POST 请求方式
@app.route(/hello, methods=[GET, POST])

带参路由

在路由中通过添加一对尖括号 <> 来包裹参数,同时该参数可以用来传递给@route所修饰的函数,但路由参数和函数参数名需相同:

# 其中只允许参数为int类型
@app.route(/hello/<int:name_id>)
def hello_flask(name_id):
    return hello %s % (name_id)

 

flask 简记

标签:请求   _id   eth   %s   允许   请求方式   int   其他   col   

原文地址:https://www.cnblogs.com/huwt/p/10941173.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!