Mr-Help commited on
Commit
a42f9f6
Β·
verified Β·
1 Parent(s): e874921

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +9 -22
main.py CHANGED
@@ -1,28 +1,15 @@
1
- from fastapi import FastAPI, HTTPException
2
- import requests
3
 
4
  app = FastAPI()
5
 
6
- # Endpoint جديد ΩŠΩ‚ΩˆΩ… Ψ¨ΨΉΩ…Ω„ request Ω„Ω„Ω€ token endpoint Ψ¨ΨͺΨ§ΨΉΩ†Ψ§
7
- @app.get("/test-token")
8
- def test_token():
9
  try:
10
- resp = requests.get("https://crmleads.binrushd.care/odoo/token", timeout=15)
11
- except requests.RequestException as e:
12
- raise HTTPException(status_code=502, detail=f"Request failed: {e}")
13
 
14
- if resp.status_code != 200:
15
- raise HTTPException(
16
- status_code=resp.status_code,
17
- detail={"error": "Bad response", "body": resp.text}
18
- )
19
 
20
- try:
21
- data = resp.json()
22
- except Exception:
23
- raise HTTPException(
24
- status_code=500,
25
- detail={"error": "Invalid JSON Response", "body": resp.text}
26
- )
27
-
28
- return {"received_token": data.get("access_token")}
 
1
+ from fastapi import FastAPI, Request
 
2
 
3
  app = FastAPI()
4
 
5
+ @app.post("/receive")
6
+ async def receive_data(request: Request):
 
7
  try:
8
+ data = await request.json()
9
+ except:
10
+ data = await request.body()
11
 
12
+ print("πŸ“₯ RECEIVED ON HF BACKEND:")
13
+ print(data)
 
 
 
14
 
15
+ return {"status": "ok", "received": data}