Spaces:
Sleeping
Sleeping
Testing
Browse files
app.py
CHANGED
|
@@ -9,20 +9,26 @@ API_TOKEN = os.environ.get('HUGGINGFACE_API_KEY')
|
|
| 9 |
HF_API_KEY = API_TOKEN
|
| 10 |
|
| 11 |
TOKEN = os.environ.get('TELEGRAM_BOT_TOKEN')
|
| 12 |
-
|
| 13 |
-
BASE_URL = f"https://149.154.167.220/bot{TOKEN}"
|
| 14 |
|
| 15 |
CUSTOM_PATH = "/gradio"
|
| 16 |
app = FastAPI()
|
| 17 |
|
| 18 |
-
|
| 19 |
|
| 20 |
@app.get("/")
|
| 21 |
-
def read_main():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
return {"message": "This is your main app"}
|
| 23 |
|
| 24 |
@app.post("/")
|
| 25 |
-
def read_main():
|
| 26 |
return {"message": "This is webhook"}
|
| 27 |
|
| 28 |
@app.post("/webhook")
|
|
@@ -31,15 +37,15 @@ async def webhook(req: Request):
|
|
| 31 |
chat_id = data['message']['chat']['id']
|
| 32 |
text = data['message']['text']
|
| 33 |
|
| 34 |
-
#msg = f"{BASE_URL}/sendMessage?chat_id={chat_id}&text={text}"
|
| 35 |
-
#await client.get(msg)
|
| 36 |
msg = f"{BASE_URL}/sendMessage?chat_id={chat_id}&text={text}"
|
| 37 |
print(msg)
|
|
|
|
|
|
|
| 38 |
#response = requests.get(msg, verify=False)
|
| 39 |
response = requests.get("https://git.io/JJkYN")
|
| 40 |
-
print(response)
|
| 41 |
|
| 42 |
-
|
| 43 |
|
| 44 |
def flip_text(x):
|
| 45 |
return x[::-1]
|
|
|
|
| 9 |
HF_API_KEY = API_TOKEN
|
| 10 |
|
| 11 |
TOKEN = os.environ.get('TELEGRAM_BOT_TOKEN')
|
| 12 |
+
BASE_URL = f"https://api.telegram.org/bot{TOKEN}"
|
| 13 |
+
#BASE_URL = f"https://149.154.167.220/bot{TOKEN}"
|
| 14 |
|
| 15 |
CUSTOM_PATH = "/gradio"
|
| 16 |
app = FastAPI()
|
| 17 |
|
| 18 |
+
client = httpx.AsyncClient()
|
| 19 |
|
| 20 |
@app.get("/")
|
| 21 |
+
async def read_main():
|
| 22 |
+
chat_id = "6688451059"
|
| 23 |
+
text = "main"
|
| 24 |
+
msg = f"{BASE_URL}/sendMessage?chat_id={chat_id}&text={text}"
|
| 25 |
+
print(msg)
|
| 26 |
+
response = requests.get(msg)
|
| 27 |
+
print(response.text)
|
| 28 |
return {"message": "This is your main app"}
|
| 29 |
|
| 30 |
@app.post("/")
|
| 31 |
+
async def read_main():
|
| 32 |
return {"message": "This is webhook"}
|
| 33 |
|
| 34 |
@app.post("/webhook")
|
|
|
|
| 37 |
chat_id = data['message']['chat']['id']
|
| 38 |
text = data['message']['text']
|
| 39 |
|
|
|
|
|
|
|
| 40 |
msg = f"{BASE_URL}/sendMessage?chat_id={chat_id}&text={text}"
|
| 41 |
print(msg)
|
| 42 |
+
await client.get(msg)
|
| 43 |
+
|
| 44 |
#response = requests.get(msg, verify=False)
|
| 45 |
response = requests.get("https://git.io/JJkYN")
|
| 46 |
+
print(response.text)
|
| 47 |
|
| 48 |
+
return data
|
| 49 |
|
| 50 |
def flip_text(x):
|
| 51 |
return x[::-1]
|