jameshns commited on
Commit
06cee5f
·
verified ·
1 Parent(s): b10afa1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -12
app.py CHANGED
@@ -66,16 +66,16 @@ bot = Bot(token=token, session=session)
66
 
67
  dp = Dispatcher()
68
 
69
- @asynccontextmanager
70
- async def lifespan(app: FastAPI):
71
- await bot.set_webhook(url='https://jameshns-btf.hf.space/webhook',
72
- allowed_updates=dp.resolve_used_update_types(),
73
- drop_pending_updates=True)
74
- yield
75
- await bot.delete_webhook()
76
 
77
 
78
- app = FastAPI(lifespan=lifespan)
79
  # app.mount("/static", StaticFiles(directory="static"), name="static")
80
  # templates = Jinja2Templates(directory="templates")
81
 
@@ -92,10 +92,10 @@ async def start(message: Message) -> None:
92
  def greet_json():
93
  return {"Hello": "World!"}
94
 
95
- @app.post("/webhook")
96
- async def webhook(request: Request) -> None:
97
- update = Update.model_validate(await request.json(), context={"bot": bot})
98
- await dp.feed_update(bot, update)
99
 
100
 
101
  if __name__ == "__main__":
 
66
 
67
  dp = Dispatcher()
68
 
69
+ # @asynccontextmanager
70
+ # async def lifespan(app: FastAPI):
71
+ # await bot.set_webhook(url='https://jameshns-btf.hf.space/webhook',
72
+ # allowed_updates=dp.resolve_used_update_types(),
73
+ # drop_pending_updates=True)
74
+ # yield
75
+ # await bot.delete_webhook()
76
 
77
 
78
+ app = FastAPI()
79
  # app.mount("/static", StaticFiles(directory="static"), name="static")
80
  # templates = Jinja2Templates(directory="templates")
81
 
 
92
  def greet_json():
93
  return {"Hello": "World!"}
94
 
95
+ # @app.post("/webhook")
96
+ # async def webhook(request: Request) -> None:
97
+ # update = Update.model_validate(await request.json(), context={"bot": bot})
98
+ # await dp.feed_update(bot, update)
99
 
100
 
101
  if __name__ == "__main__":