Update main.py
Browse files
main.py
CHANGED
|
@@ -1,28 +1,15 @@
|
|
| 1 |
-
from fastapi import FastAPI,
|
| 2 |
-
import requests
|
| 3 |
|
| 4 |
app = FastAPI()
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
def test_token():
|
| 9 |
try:
|
| 10 |
-
|
| 11 |
-
except
|
| 12 |
-
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
status_code=resp.status_code,
|
| 17 |
-
detail={"error": "Bad response", "body": resp.text}
|
| 18 |
-
)
|
| 19 |
|
| 20 |
-
|
| 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}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|