-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathteste.py
More file actions
37 lines (26 loc) · 994 Bytes
/
Copy pathteste.py
File metadata and controls
37 lines (26 loc) · 994 Bytes
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
37
from fastapi import FastAPI, HTTPException, Request
from pydantic import BaseModel
from typing import Optional
import requests
app = FastAPI()
class ChatwootEvent(BaseModel):
event: str
data: dict
@app.post("/chatwoot/webhook")
async def chatwoot_webhook(media_url: str):
try:
response = requests.get(media_url)
if response.status_code == 200:
# Faça o processamento desejado com o conteúdo da imagem
image_data = response.content
# Salve ou redirecione para EvolutionAPI, conforme necessário
except requests.exceptions.RequestException as e:
raise HTTPException(status_code=500, detail="Erro ao acessar a mídia")
return {"status": "success"}
@app.get("/webhook/chatwoot")
async def webhook_health_check():
return {"status": "Webhook is active"}
if __name__ == '__main__':
import uvicorn
uvicorn.run("teste:app", host="0.0.0.0", port=8001,
log_level='info', reload=True)