美文网首页
Flask request浅析

Flask request浅析

作者: Alex_Dj | 来源:发表于2018-04-07 17:33 被阅读0次

request的作用

你可以使用全局 request 对象访问进入的请求数据。 Flask 处理进入的请求数据并允许你用这个全局对象访问它。如果你工作在多线程环境,Flask 内部保证你总会在当前线程上获取正确的数据

request请求及参数获取

请求类型

  • get请求
    访问时会在地址栏直接显示参数不安全,且参数大小比较小。
  • post请求
    参数不显示在地址栏,一般用户注册、登录都通过post请求完成。

参数获取

request.form.get("key", type=str, default=None) 获取表单数据
request.args.get("key") 获取get请求参数
request.values.get("key") 获取所有参数

flask.Request.args
A MultiDict with the parsed contents of the query string. (The part in the URL after the question mark).
So the args.get() is method get() for [MultiDict]

get(key, default=None, type=None)

相关文章

网友评论

      本文标题:Flask request浅析

      本文链接:https://www.haomeiwen.com/subject/elbyhftx.html