api.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:duckpond 作者: alexmilowski 项目源码 文件源码
def content():
   if request.method == 'GET':
      works = model.getContentList()
      return jsonld_response(json.dumps(works))

   if request.method == 'POST':
      # Parse the incoming JSON-LD data
      force = request.headers['Content-Type'].startswith('application/ld+json')
      data = request.get_json(force=force)
      if data is None:
         abort(400)
      if 'name' not in data or \
         'genre' not in data or \
         'headline' not in data or \
         '@type' not in data:
         abort(400)
      status,url,modified = model.createContent(data['@type'],data['genre'],data['name'],data['headline'])
      return Response(status=status,headers=({'Location' : url, 'Date-Modified' : modified} if status==201 else {}))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号