app.py 文件源码

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

项目:quizbot-2017 作者: pycontw 项目源码 文件源码
def configure_linebot_app(app):

    @app.after_request
    def commit_database(response):
        db.commit()
        return response

    @app.route("/api/line_webhook", methods=["POST"])
    def line_webhook():
        signature = request.headers['X-Line-Signature']
        body = request.get_data(as_text=True)
        logger.debug(f'Incoming message:\n{pformat(body)}')
        try:
            line_webhook_handler.handle(body, signature)
        except InvalidSignatureError:
            logger.warning('Message with an invalid signature received')
            abort(400)
        except LineBotApiError as e:
            logger.error(f'{e}\nDetails:\n{pformat(e.error.details)}')
            abort(500)
        except Exception as e:
            logger.error(f'Uncaught error: {e}')
            abort(500)
        return "OK"
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号