|
from fastapi import FastAPI, Request |
|
import uvicorn |
|
|
|
app = FastAPI() |
|
|
|
@app.get("/") |
|
async def root(): |
|
return {"message": "TEST BOT", "status": "working"} |
|
|
|
@app.get("/health") |
|
async def health(): |
|
return {"status": "healthy"} |
|
|
|
@app.post("/whatsapp-webhook") |
|
async def webhook(request: Request): |
|
try: |
|
form_data = await request.form() |
|
from_number = form_data.get('From', 'unknown') |
|
body = form_data.get('Body', 'empty') |
|
print(f"MESAJ: {from_number} -> {body}") |
|
return {"status": "received", "message": f"Got: {body}"} |
|
except Exception as e: |
|
print(f"ERROR: {e}") |
|
return {"status": "error"} |
|
|
|
@app.get("/whatsapp-webhook") |
|
async def webhook_get(): |
|
return {"message": "Webhook çalışıyor", "method": "GET"} |
|
|
|
if __name__ == "__main__": |
|
uvicorn.run(app, host="0.0.0.0", port=7860) |