From 0e4e0e17c2b03bd8939f3c8683cc1d09128e18a2 Mon Sep 17 00:00:00 2001 From: Dmitry Afanasyev Date: Fri, 26 Aug 2022 00:09:54 +0300 Subject: [PATCH] add health check --- app/main.py | 5 +++++ app/settings.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index 52bcf77..be54a00 100644 --- a/app/main.py +++ b/app/main.py @@ -75,6 +75,10 @@ async def put_updates_on_queue(request: web.Request) -> web.Response: return web.Response(status=HTTPStatus.ACCEPTED) +async def health_check(request: web.Request) -> web.Response: + return web.Response(text='Health OK', status=HTTPStatus.OK) + + async def get_updates_from_queue() -> None: while True: @@ -85,6 +89,7 @@ async def get_updates_from_queue() -> None: async def create_app() -> web.Application: application = web.Application() + application.router.add_get('/', health_check) application.router.add_post( f'{WEBHOOK_PATH}/{TELEGRAM_API_TOKEN}', put_updates_on_queue ) diff --git a/app/settings.py b/app/settings.py index 7341dc8..a7d1314 100644 --- a/app/settings.py +++ b/app/settings.py @@ -16,7 +16,7 @@ config = AutoConfig(search_path=env_path) GECKO_DRIVER_VERSION = config('GECKO_DRIVER_VERSION', default='0.31.0') TELEGRAM_API_TOKEN = config( - 'API_TOKEN', default='123456789:AABBCCDDEEFFaabbccddeeff-1234567890' + 'TELEGRAM_API_TOKEN', default='123456789:AABBCCDDEEFFaabbccddeeff-1234567890' ) # webhook settings