views.py 文件源码

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

项目:aiohttp_admin 作者: aio-libs 项目源码 文件源码
def vote(self, request):
        question_id = int(request.match_info['question_id'])
        data = await request.post()
        try:
            choice_id = int(data['choice'])
        except (KeyError, TypeError, ValueError) as e:
            raise web.HTTPBadRequest(
                text='You have not specified choice value') from e
        try:
            await db.vote(self.postgres, question_id, choice_id)
        except db.RecordNotFound as e:
            raise web.HTTPNotFound(text=str(e))
        router = request.app.router
        url = router['results'].url(parts={'question_id': question_id})
        return web.HTTPFound(location=url)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号