Ajout du frontend et branchement sur l'API axione #9

Merged
felix.baylac merged 21 commits from johan/frontend into master 2022-02-13 19:39:12 +01:00
2 changed files with 29 additions and 2 deletions
Showing only changes of commit 01c8f2b37b - Show all commits

View file

@ -23,9 +23,34 @@ def ptoRequest(ptoRef):
</soapenv:Envelope>
"""
def fantoirRequest(insee, rivoli, numVoie):
ts = datetime.now(timezone.utc).isoformat()
return f"""
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ent="http://structureadresseftth.axione.fr/model/entreprise" xmlns:com="http://structureadresseftth.axione.fr/model/commun">
<soapenv:Header/>
<soapenv:Body>
<ent:obtentionStructureAdresseDemandeSoap>
<ent:entete versionWS="3.0" horodatageRequete="{ts}">
<com:operateurCommercial nom="AQUILENET" identifiant=""/>
</ent:entete>
<ent:referenceAdresse>
<com:referenceRivoli codeInsee="{insee}" codeRivoli="{rivoli}" numeroVoie="{numvoie}"/>
</ent:referenceAdresse>
</ent:obtentionStructureAdresseDemandeSoap>
</soapenv:Body>
</soapenv:Envelope>
"""
def query_axione_fantoir(cfg, insee, rivoli, numVoie):
body = fantoirRequest(insee, rivoli, numVoie)
query_axione(cfg, body)
def query_axione_pto(cfg, ptoRef):
body = ptoRequest(ptoRef)
query_axione(cfg, body)
def query_axione(cfg, body):
# Note: the password should be the base64 of username:password.
# Don't ask why.
passwd = base64.b64encode(f"{cfg.username}:{cfg.password}".encode("utf8")).decode(

View file

@ -56,9 +56,11 @@ def get_fantoir_voies(codeInsee):
def test_address():
commune = escape(request.form['commune'])
numeroVoie = escape(request.form['numeroVoie'])
voie = escape(request.form['voie'])
# Trimming rivoli's key
voie = escape(request.form['voie'])[:-1]
result = query_axione_fantoir(cfg, commune, voie, numeroVoie)
# result = parse_response(query_axione_pto(cfg, pto))
return json.dumps({'success':True}), 200, {'ContentType':'application/json'}
return render_template("result.html", pto="", result=result)
@app.route("/test/pto", methods=['POST'])