Spaces:
Running
Running
File size: 1,169 Bytes
01ff0c1 002fca8 eadded2 70dc730 d707be1 23d7e0d 11c5c73 01ff0c1 11c5c73 23d7e0d eadded2 6159237 09a8c2d b32b0d3 01ff0c1 23d7e0d ce65594 13a597c ce65594 13a597c 01ff0c1 09a8c2d 79f7735 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
#import httpx
from fastapi import FastAPI, Request
from fastapi.middleware.cors import CORSMiddleware # Importa il middleware CORS
import requests
TOKEN = "6770617809:AAEhytQUOl3uZOFINVE7-o0KkIoAz8perGU"
BASE_URL = f"https://api.telegram.org/bot{TOKEN}"
#client = httpx.AsyncClient()
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
#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("https://api.telegram.org/bot6770617809:AAEhytQUOl3uZOFINVE7-o0KkIoAz8perGU/sendMessage?chat_id=1738997897&text=Come_Stai_Vez")
#resp = requests.get(f"{BASE_URL}/sendMessage?chat_id={chat_id}&text={text}")
#print(resp)
#await client.get(f"{BASE_URL}/sendMessage?chat_id={chat_id}&text={text}")
return {"response": "ok"}
@app.get("/")
def read_general():
return {"response": "Started"} |