api_server.py 文件源码

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

项目:gold-digger 作者: business-factory 项目源码 文件源码
def on_get(self, req, resp):
        try:
            exchange_rate = self.container.exchange_rate_manager.get_exchange_rate_by_date(date.today(), "USD", "USD")
            if exchange_rate:
                resp.body = '{"status": "UP"}'
            else:
                resp.body = '{"status": "DOWN", "info": "No exchange rate available."}'

        except DatabaseError as e:
            self.container.db_session.rollback()
            resp.body = '{"status": "DOWN", "info": "Database error. Service will reconnect to the DB automatically. Exception: %s"}' % e
        except Exception as e:
            resp.body = '{"status": "DOWN", "info": "%s"}' % e

        resp.status = falcon.HTTP_200
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号