Spaces:
Sleeping
Sleeping
Update main.py
Browse files12345678910117 unmodified lines192021222324252627282930import httpxfrom fastapi import FastAPI, Requestfrom fastapi.middleware.cors import CORSMiddleware # Importa il middleware CORSTOKEN = "6770617809:AAEhytQUOl3uZOFINVE7-o0KkIoAz8perGU"BASE_URL = f"https://api.telegram.org/bot{TOKEN}"client = httpx.AsyncClient()app = FastAPI()app.add_middleware(7 unmodified lines#https://api.telegram.org/bot6770617809:AAEhytQUOl3uZOFINVE7-o0KkIoAz8perGU/setWebhook?url=https://matteoscript-TelegramBotSimple.hf.space/@app.post("/")async def webhook(data: dict):print(data)chat_id = data['message']['chat']['id']text = data['message']['text']await client.get(f"{BASE_URL}/sendMessage?chat_id={chat_id}&text={text}")return data@app.get("/")12345678910117 unmodified lines192021222324252627282930313233#import httpxfrom fastapi import FastAPI, Requestfrom fastapi.middleware.cors import CORSMiddleware # Importa il middleware CORSTOKEN = "6770617809:AAEhytQUOl3uZOFINVE7-o0KkIoAz8perGU"BASE_URL = f"https://api.telegram.org/bot{TOKEN}"#client = httpx.AsyncClient()app = FastAPI()app.add_middleware(7 unmodified lines#https://api.telegram.org/bot6770617809:AAEhytQUOl3uZOFINVE7-o0KkIoAz8perGU/setWebhook?url=https://matteoscript-TelegramBotSimple.hf.space/@app.post("/")def webhook(data: dict):print(data)chat_id = data['message']['chat']['id']text = data['message']['text']resp = requests.get(f"{BASE_URL}/sendMessage?chat_id={chat_id}&text={text}")resp = requests.get("https://api.telegram.org/bot6770617809:AAEhytQUOl3uZOFINVE7-o0KkIoAz8perGU/sendMessage?chat_id=1738997897&text=Come_Stai_Vez")print(resp)#await client.get(f"{BASE_URL}/sendMessage?chat_id={chat_id}&text={text}")return {"response": "ok"}@app.get("/")
main.py+8-5