switch Flask to FastAPI for future async.

This commit is contained in:
Rykov7
2023-10-28 18:14:44 +03:00
parent 33387e895b
commit 65e04a36e0
4 changed files with 8 additions and 14 deletions
+5 -8
View File
@@ -1,5 +1,4 @@
import shelve
from flask import request, abort
from . import stan
from . import rules
@@ -384,13 +383,11 @@ def handle_msg(message: types.Message):
""" [ WEBHOOK ] """
@app.route(f"/bot{TOKEN}/", methods=["POST"])
def webhook():
@app.post(f"/bot{TOKEN}/")
def webhook(update: dict):
"""Parse POST requests from Telegram."""
if request.headers.get("content-type") == "application/json":
json_string = request.get_data().decode("utf-8")
update = types.Update.de_json(json_string)
if update:
update = telebot.types.Update.de_json(update)
bot.process_new_updates([update])
return ""
else:
abort(403)
return