Ajout du frontend et branchement sur l'API axione #9
1 changed files with 5 additions and 7 deletions
|
@ -43,19 +43,17 @@ def fantoirRequest(insee, rivoli, numVoie):
|
||||||
|
|
||||||
def query_axione_fantoir(cfg, insee, rivoli, numVoie):
|
def query_axione_fantoir(cfg, insee, rivoli, numVoie):
|
||||||
body = fantoirRequest(insee, rivoli, numVoie)
|
body = fantoirRequest(insee, rivoli, numVoie)
|
||||||
query_axione(cfg, body)
|
return query_axione(cfg, body)
|
||||||
|
|
||||||
|
|
||||||
def query_axione_pto(cfg, ptoRef):
|
def query_axione_pto(cfg, ptoRef):
|
||||||
body = ptoRequest(ptoRef)
|
body = ptoRequest(ptoRef)
|
||||||
query_axione(cfg, body)
|
return query_axione(cfg, body)
|
||||||
|
|
||||||
def query_axione(cfg, body):
|
def query_axione(cfg, body):
|
||||||
# Note: the password should be the base64 of username:password.
|
# Note: the password should be the base64 of username:password.
|
||||||
# Don't ask why.
|
# Don't ask why.
|
||||||
passwd = base64.b64encode(f"{cfg.username}:{cfg.password}".encode("utf8")).decode(
|
passwd = cfg.password
|
||||||
"utf8"
|
|
||||||
)
|
|
||||||
headers = {
|
headers = {
|
||||||
"User-Agent": "aquilenet-elig-test/0.1",
|
"User-Agent": "aquilenet-elig-test/0.1",
|
||||||
"Accept": "*/*",
|
"Accept": "*/*",
|
||||||
|
@ -63,7 +61,7 @@ def query_axione(cfg, body):
|
||||||
"Connection": "Keep-Alive",
|
"Connection": "Keep-Alive",
|
||||||
"Authorization": passwd,
|
"Authorization": passwd,
|
||||||
}
|
}
|
||||||
resp = None
|
respData = None
|
||||||
if not cfg.debug:
|
if not cfg.debug:
|
||||||
try:
|
try:
|
||||||
conn = http.client.HTTPSConnection(
|
conn = http.client.HTTPSConnection(
|
||||||
|
@ -96,7 +94,7 @@ def query_axione(cfg, body):
|
||||||
with open("./fixtures/dummy-data-1.xml", "r") as f:
|
with open("./fixtures/dummy-data-1.xml", "r") as f:
|
||||||
dummyData = f.read()
|
dummyData = f.read()
|
||||||
return dummyData
|
return dummyData
|
||||||
return resp
|
return respData
|
||||||
|
|
||||||
|
|
||||||
class LigneResult(TypedDict):
|
class LigneResult(TypedDict):
|
||||||
|
|
Loading…
Reference in a new issue