Spaces:
Sleeping
Sleeping
Commit
•
40b32ad
1
Parent(s):
d658933
Update main.py
Browse files
main.py
CHANGED
@@ -1,12 +1,18 @@
|
|
|
|
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"
|
10 |
response = requests.get(url)
|
11 |
if response.status_code == 200:
|
12 |
response_json = json.loads(response.text)
|
@@ -18,12 +24,12 @@ async def get_eatc_headers(eatc_code: str = Query(..., description="EATC code to
|
|
18 |
eatc_pod_id_value = response_json["res"][0].get("eatc-pod_id", "")
|
19 |
|
20 |
# Realizar la segunda consulta
|
21 |
-
second_url = f"
|
22 |
second_response = requests.get(second_url)
|
23 |
eatc_asignacion_directa = "SI" if second_response.status_code == 200 else "NO"
|
24 |
|
25 |
# Realizar la tercera consulta
|
26 |
-
third_url = f"
|
27 |
third_response = requests.get(third_url)
|
28 |
third_response_json = json.loads(third_response.text)
|
29 |
eatc_match_cantidad = len(third_response_json)
|
|
|
1 |
+
import os
|
2 |
from fastapi import FastAPI, Query, Response
|
3 |
import requests
|
4 |
import json
|
5 |
|
6 |
app = FastAPI()
|
7 |
|
8 |
+
# Leer las variables secretas
|
9 |
+
url_base = os.getenv("URL_BASE")
|
10 |
+
second_url_base = os.getenv("SECOND_URL_BASE")
|
11 |
+
third_url_base = os.getenv("THIRD_URL_BASE")
|
12 |
+
|
13 |
@app.get("/eatc-headers")
|
14 |
async def get_eatc_headers(eatc_code: str = Query(..., description="EATC code to retrieve headers for")):
|
15 |
+
url = f"{url_base}/api/abaco/eatc_dona_headers?eatc-code={eatc_code}"
|
16 |
response = requests.get(url)
|
17 |
if response.status_code == 200:
|
18 |
response_json = json.loads(response.text)
|
|
|
24 |
eatc_pod_id_value = response_json["res"][0].get("eatc-pod_id", "")
|
25 |
|
26 |
# Realizar la segunda consulta
|
27 |
+
second_url = f"{second_url_base}/api/eatcloud/eatc_direct_dona?eatc_pod_id={eatc_pod_id_value}"
|
28 |
second_response = requests.get(second_url)
|
29 |
eatc_asignacion_directa = "SI" if second_response.status_code == 200 else "NO"
|
30 |
|
31 |
# Realizar la tercera consulta
|
32 |
+
third_url = f"{third_url_base}/api/abaco/eatc_match_registry?eatc-dona_header_code={eatc_code_value}"
|
33 |
third_response = requests.get(third_url)
|
34 |
third_response_json = json.loads(third_response.text)
|
35 |
eatc_match_cantidad = len(third_response_json)
|