Spaces:
Sleeping
Sleeping
Commit
•
c871f28
1
Parent(s):
fb262d5
Update main.py
Browse files
main.py
CHANGED
@@ -2,7 +2,7 @@ from fastapi import FastAPI, Query
|
|
2 |
from pydantic import BaseModel
|
3 |
import requests
|
4 |
import json
|
5 |
-
|
6 |
|
7 |
app = FastAPI()
|
8 |
|
@@ -16,12 +16,12 @@ async def get_eatc_headers(eatc_code: str = Query(..., description="EATC code to
|
|
16 |
if response.status_code == 200:
|
17 |
response_json = json.loads(response.text)
|
18 |
if len(response_json) >= 2 and "res" in response_json and response_json["res"]:
|
19 |
-
data =
|
20 |
-
"eatc_code"
|
21 |
-
"eatc_match_asignation_rule"
|
22 |
-
|
23 |
-
|
24 |
-
return {"report":
|
25 |
else:
|
26 |
return {"error": "Invalid response from API"}
|
27 |
else:
|
|
|
2 |
from pydantic import BaseModel
|
3 |
import requests
|
4 |
import json
|
5 |
+
from tabulate import tabulate
|
6 |
|
7 |
app = FastAPI()
|
8 |
|
|
|
16 |
if response.status_code == 200:
|
17 |
response_json = json.loads(response.text)
|
18 |
if len(response_json) >= 2 and "res" in response_json and response_json["res"]:
|
19 |
+
data = [
|
20 |
+
["eatc_code", response_json["res"][0]["eatc-code"]],
|
21 |
+
["eatc_match_asignation_rule", response_json["res"][0].get("eatc_match_asignation_rule", "")]
|
22 |
+
]
|
23 |
+
report = tabulate(data, headers="firstrow", tablefmt="grid")
|
24 |
+
return {"report": report}
|
25 |
else:
|
26 |
return {"error": "Invalid response from API"}
|
27 |
else:
|