Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -1,11 +1,11 @@
|
|
| 1 |
-
import httpx
|
| 2 |
from fastapi import FastAPI, Request
|
| 3 |
from fastapi.middleware.cors import CORSMiddleware # Importa il middleware CORS
|
| 4 |
|
| 5 |
TOKEN = "6770617809:AAEhytQUOl3uZOFINVE7-o0KkIoAz8perGU"
|
| 6 |
BASE_URL = f"https://api.telegram.org/bot{TOKEN}"
|
| 7 |
|
| 8 |
-
client = httpx.AsyncClient()
|
| 9 |
|
| 10 |
app = FastAPI()
|
| 11 |
app.add_middleware(
|
|
@@ -19,12 +19,13 @@ app.add_middleware(
|
|
| 19 |
@app.post("/")
|
| 20 |
async def webhook(req: Request):
|
| 21 |
print('a')
|
| 22 |
-
data =
|
| 23 |
print(data)
|
| 24 |
-
chat_id = data['message']['chat']['id']
|
| 25 |
-
text = data['message']['text']
|
| 26 |
-
await client.get(f"{BASE_URL}/sendMessage?chat_id={chat_id}&text={text}")
|
| 27 |
-
return data
|
|
|
|
| 28 |
|
| 29 |
@app.get("/")
|
| 30 |
def read_general():
|
|
|
|
| 1 |
+
#import httpx
|
| 2 |
from fastapi import FastAPI, Request
|
| 3 |
from fastapi.middleware.cors import CORSMiddleware # Importa il middleware CORS
|
| 4 |
|
| 5 |
TOKEN = "6770617809:AAEhytQUOl3uZOFINVE7-o0KkIoAz8perGU"
|
| 6 |
BASE_URL = f"https://api.telegram.org/bot{TOKEN}"
|
| 7 |
|
| 8 |
+
#client = httpx.AsyncClient()
|
| 9 |
|
| 10 |
app = FastAPI()
|
| 11 |
app.add_middleware(
|
|
|
|
| 19 |
@app.post("/")
|
| 20 |
async def webhook(req: Request):
|
| 21 |
print('a')
|
| 22 |
+
data = req.json()
|
| 23 |
print(data)
|
| 24 |
+
#chat_id = data['message']['chat']['id']
|
| 25 |
+
#text = data['message']['text']
|
| 26 |
+
#await client.get(f"{BASE_URL}/sendMessage?chat_id={chat_id}&text={text}")
|
| 27 |
+
#return data
|
| 28 |
+
return {"response": "aaa"}
|
| 29 |
|
| 30 |
@app.get("/")
|
| 31 |
def read_general():
|