mirror of
https://github.com/Balshgit/mosgortrans.git
synced 2025-09-11 13:00:40 +03:00
webhook url with token
This commit is contained in:
parent
cb22194067
commit
2489157728
17
app/main.py
17
app/main.py
@ -7,7 +7,14 @@ from aiohttp import web
|
|||||||
from app.core.bot import bot, dispatcher
|
from app.core.bot import bot, dispatcher
|
||||||
from app.core.logger import logger
|
from app.core.logger import logger
|
||||||
from app.core.scheduler import asyncio_schedule
|
from app.core.scheduler import asyncio_schedule
|
||||||
from app.settings import START_WITH_WEBHOOK, WEBAPP_HOST, WEBAPP_PORT, WEBHOOK_URL
|
from app.settings import (
|
||||||
|
API_TOKEN,
|
||||||
|
START_WITH_WEBHOOK,
|
||||||
|
WEBAPP_HOST,
|
||||||
|
WEBAPP_PORT,
|
||||||
|
WEBHOOK_PATH,
|
||||||
|
WEBHOOK_URL,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def bot_startup() -> None:
|
async def bot_startup() -> None:
|
||||||
@ -75,15 +82,9 @@ async def webhook(request: web.Request) -> web.Response:
|
|||||||
return web.Response(status=HTTPStatus.OK)
|
return web.Response(status=HTTPStatus.OK)
|
||||||
|
|
||||||
|
|
||||||
async def hello_world(request: web.Request) -> web.Response:
|
|
||||||
logger.info(request)
|
|
||||||
return web.Response(body='Hello World')
|
|
||||||
|
|
||||||
|
|
||||||
async def create_app() -> web.Application:
|
async def create_app() -> web.Application:
|
||||||
application = web.Application()
|
application = web.Application()
|
||||||
application.router.add_post('/', webhook)
|
application.router.add_post(f'/{WEBHOOK_PATH}/{API_TOKEN}', webhook)
|
||||||
application.router.add_post('/hello', hello_world)
|
|
||||||
application.on_startup.append(on_startup_gunicorn)
|
application.on_startup.append(on_startup_gunicorn)
|
||||||
application.on_shutdown.append(on_shutdown_gunicorn)
|
application.on_shutdown.append(on_shutdown_gunicorn)
|
||||||
return application
|
return application
|
||||||
|
@ -20,7 +20,7 @@ API_TOKEN = config('API_TOKEN', default='123456789:AABBCCDDEEFFaabbccddeeff-1234
|
|||||||
# webhook settings
|
# webhook settings
|
||||||
WEBHOOK_HOST = config('WEBHOOK_HOST', default='')
|
WEBHOOK_HOST = config('WEBHOOK_HOST', default='')
|
||||||
WEBHOOK_PATH = config('WEBHOOK_PATH', default='')
|
WEBHOOK_PATH = config('WEBHOOK_PATH', default='')
|
||||||
WEBHOOK_URL = f"{WEBHOOK_HOST}{WEBHOOK_PATH}"
|
WEBHOOK_URL = f"{WEBHOOK_HOST}{WEBHOOK_PATH}/{API_TOKEN}"
|
||||||
|
|
||||||
# webserver settings
|
# webserver settings
|
||||||
WEBAPP_HOST = config('WEBAPP_HOST', default='127.0.0.1') # or ip
|
WEBAPP_HOST = config('WEBAPP_HOST', default='127.0.0.1') # or ip
|
||||||
|
Loading…
x
Reference in New Issue
Block a user