Spaces:
Sleeping
Sleeping
mobixconsulting
commited on
Commit
•
c7a9eee
1
Parent(s):
eeb2ae5
Update main.py
Browse files
main.py
CHANGED
@@ -1,14 +1,10 @@
|
|
1 |
-
from fastapi import FastAPI, Query
|
2 |
-
from pydantic import BaseModel
|
3 |
import requests
|
4 |
import json
|
5 |
|
6 |
app = FastAPI()
|
7 |
|
8 |
-
|
9 |
-
report: str
|
10 |
-
|
11 |
-
@app.get("/eatc-headers", response_class=HTMLResponse)
|
12 |
async def get_eatc_headers(eatc_code: str = Query(..., description="EATC code to retrieve headers for")):
|
13 |
url = f"https://donantes.eatcloud.info/api/abaco/eatc_dona_headers?eatc-code={eatc_code}"
|
14 |
response = requests.get(url)
|
@@ -20,8 +16,8 @@ async def get_eatc_headers(eatc_code: str = Query(..., description="EATC code to
|
|
20 |
|
21 |
report = f"<p>eatc_code: {eatc_code_value}</p><p>eatc_match_asignation_rule: {eatc_match_asignation_rule_value}</p>"
|
22 |
|
23 |
-
return
|
24 |
else:
|
25 |
-
return
|
26 |
else:
|
27 |
-
return
|
|
|
1 |
+
from fastapi import FastAPI, Query, Response
|
|
|
2 |
import requests
|
3 |
import json
|
4 |
|
5 |
app = FastAPI()
|
6 |
|
7 |
+
@app.get("/eatc-headers")
|
|
|
|
|
|
|
8 |
async def get_eatc_headers(eatc_code: str = Query(..., description="EATC code to retrieve headers for")):
|
9 |
url = f"https://donantes.eatcloud.info/api/abaco/eatc_dona_headers?eatc-code={eatc_code}"
|
10 |
response = requests.get(url)
|
|
|
16 |
|
17 |
report = f"<p>eatc_code: {eatc_code_value}</p><p>eatc_match_asignation_rule: {eatc_match_asignation_rule_value}</p>"
|
18 |
|
19 |
+
return Response(content=report, media_type="text/html")
|
20 |
else:
|
21 |
+
return Response(content="<p>Error: Invalid response from API</p>", media_type="text/html", status_code=400)
|
22 |
else:
|
23 |
+
return Response(content="<p>Error: API returned error status code</p>", media_type="text/html", status_code=400)
|