request.form及request.args的区别

request.form用来接受post请求参数,request.args接受get请求参数。以requests.form[‘key’],若值不存在,抛出KeyError,会直接返回400错误,可以手动捕获。如下

def login():
    try:
        username = request.args['name']
        password = request.form['pass']
    except KeyError as e:
        print(e)

request.args同理。
此外,可以使用字典的get方法避免异常。eg.request.form.get('key',none)

‘dict’ object is not callable解决办法

manager.add_command('shell',Shell(make_context=make_shell_context()))

改为:

manager.add_command('shell',Shell(make_context=make_shell_context))
posted on 2017-11-20 14:51  岚漾忆雨  阅读(39)  评论(0)    收藏  举报