本文整理汇总了Python中flask.Request.get_json方法的典型用法代码示例。如果您正苦于以下问题:Python Request.get_json方法的具体用法?Python Request.get_json怎么用?Python Request.get_json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flask.Request
的用法示例。
在下文中一共展示了Request.get_json方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: res_post
# 需要导入模块: from flask import Request [as 别名]
# 或者: from flask.Request import get_json [as 别名]
def res_post(uid: str):
if know_post(uid):
if not Request.get_json(request):
apo_post = post_factory.post_factory(uid)
apo_post.apothanasia()
return Response(json.dumps(vars(apo_post)), 200)
req = Request.get_json(request)
tmp_post = response_post.ResponsePost(link=uid, content=req['content'],
password=req['password'] if 'password' in Request.get_json(request) else '',
lang=req['lang'] if 'lang' in Request.get_json(request) else 'und')
tmp_post.post_contribution()
return Response(json.dumps(vars(tmp_post)), 200)
示例2: delete_post
# 需要导入模块: from flask import Request [as 别名]
# 或者: from flask.Request import get_json [as 别名]
def delete_post(uid):
if know_post(uid):
if not Request.get_json(request):
req = Request.get_Json(request)
if not 'password' in req:
abort(400)
req = Request.get_json(request)
tmp_post = post_factory.post_factory(uid)
if not tmp_post.password == req['password']:
abort(401)
else:
tmp_post.delete_post()
return Response(json.dumps({'message': 'Your post deleted ;)'}), 200)
示例3: post_content
# 需要导入模块: from flask import Request [as 别名]
# 或者: from flask.Request import get_json [as 别名]
def post_content():
if not Request.get_json(request):
abort(400)
req = Request.get_json(request)
if not 'content' in req:
abort(400)
if len(req['content']) <= 0:
abort(123)
tmp_post = post.Post(content=req['content'],
password=req['password'] if 'password' in Request.get_json(request) else '',
lang=req['lang'] if 'lang' in Request.get_json(request) else 'und')
tmp_post.post_contribution()
return Response(json.dumps(vars(tmp_post)), 200)