Browse Source
We add a small flask-powered web application in charge of retrieving the PBO-related data from axione.master
6 changed files with 170 additions and 4 deletions
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash |
||||
|
||||
DEBUG=true CONFIG=./elig-test.ini.sample FLASK_APP=webapp poetry run flask run --reload |
@ -0,0 +1,25 @@
|
||||
<!doctype html> |
||||
|
||||
<html lang="fr"> |
||||
<head> |
||||
<meta charset="utf-8"> |
||||
<meta name="viewport" content="width=device-width, initial-scale=1"> |
||||
<title>Aquilenet: Éligibilité FTTH</title> |
||||
<style> |
||||
{% include 'style.css' %} |
||||
</style> |
||||
</head> |
||||
|
||||
<body> |
||||
<h1 id="aquilenet-title">Aquilenet</h1> |
||||
<div id="container"> |
||||
<h1 id="main-title">Test d'Éligibilité FTTH Aquilenet</h1> |
||||
<form method="post" action="/result"> |
||||
<label>Numéro de PTO : |
||||
<input name="pto"/> |
||||
</label> |
||||
<button>Tester</button> |
||||
</form> |
||||
</div> |
||||
</body> |
||||
</html> |
@ -0,0 +1,62 @@
|
||||
<!doctype html> |
||||
|
||||
<html lang="fr"> |
||||
<head> |
||||
<meta charset="utf-8"> |
||||
<meta name="viewport" content="width=device-width, initial-scale=1"> |
||||
<title>Aquilenet: Éligibilité FTTH</title> |
||||
<style> |
||||
{% include 'style.css' %} |
||||
</style> |
||||
</head> |
||||
|
||||
<body> |
||||
<h1 id="aquilenet-title">Aquilenet</h1> |
||||
<div id="container"> |
||||
<h1 id="main-title">Test d'Éligibilité FTTH Aquilenet: Résultats</h1> |
||||
<p>Résultat pour le PTO: {{ pto }}</p> |
||||
{% for batiment in result %} |
||||
<table> |
||||
<thead> |
||||
<tr> |
||||
<th colspan="100">{{ batiment["referenceBatiment"] }}</th> |
||||
</tr> |
||||
</thead> |
||||
{% for etage in batiment["etages"] %} |
||||
<tr> |
||||
<td>{{ etage["reference"] }}</td> |
||||
<td> |
||||
<table> |
||||
<tr><td>Nb Lignes Actives</td><td>{{ etage["nbLignesActives"] }}</td></tr> |
||||
<tr><td>Nb Lignes Existantes</td><td>{{ etage["nbLignesExistantes"] }}</td></tr> |
||||
<tr><td>Nb Locaux FTTH</td><td>{{ etage["nbLocauxFtth"] }}</td></tr> |
||||
<tr> |
||||
<td> |
||||
<table> |
||||
<thead> |
||||
<tr><th colspan="100">Lignes</th></tr> |
||||
<tr><td>PTO</td><td>PBO</td><td>actif</td><td>commercialisable</td><td>existant</td><td>raccordable</td><td>rompu</td></tr> |
||||
</thead> |
||||
{% for ligne in etage["lignes"] %} |
||||
<tr> |
||||
<td>{{ ligne["pto"] }}</td> |
||||
<td>{{ ligne["pbo"] }}</td> |
||||
<td>{{ ligne["actif"] }}</td> |
||||
<td>{{ ligne["commercialisable"] }}</td> |
||||
<td>{{ ligne["existant"] }}</td> |
||||
<td>{{ ligne["raccordable"] }}</td> |
||||
<td>{{ ligne["rompu"] }}</td> |
||||
</tr> |
||||
{% endfor %} |
||||
</table> |
||||
</td> |
||||
</tr> |
||||
</table> |
||||
</td> |
||||
</tr> |
||||
{% endfor %} |
||||
</table> |
||||
{% endfor %} |
||||
</div> |
||||
</body> |
||||
</html> |
@ -0,0 +1,46 @@
|
||||
body { |
||||
background-color: #1787c2; |
||||
display: flex; |
||||
flex-direction: column; |
||||
font-family: 'Titillium Web', sans-serif; |
||||
} |
||||
#aquilenet-title { |
||||
color: white; |
||||
align-self: center; |
||||
font-size: 4em; |
||||
margin-top: .3em; |
||||
margin-bottom: .5em; |
||||
} |
||||
#container { |
||||
width: 80%; |
||||
background-color: #ffd38c; |
||||
align-self: center; |
||||
padding: 2em; |
||||
display: flex; |
||||
flex-direction: column; |
||||
padding-bottom: 10em; |
||||
} |
||||
|
||||
form { |
||||
align-self: center; |
||||
} |
||||
|
||||
#main-title { |
||||
align-self: center; |
||||
margin-bottom: 2em; |
||||
} |
||||
|
||||
table,td { |
||||
border: 2px solid #333; |
||||
border-collapse: collapse; |
||||
} |
||||
|
||||
thead, tfoot { |
||||
background-color: #333; |
||||
color: #fff; |
||||
} |
||||
|
||||
td { |
||||
padding-left: 1em; |
||||
padding-right: 1em; |
||||
} |
@ -0,0 +1,32 @@
|
||||
import os |
||||
from flask import Flask, render_template, request, escape |
||||
|
||||
from axione_api.config import parse_config |
||||
from axione_api.api import query_axione_pto, parse_response |
||||
|
||||
def load_config(): |
||||
cfg_path = os.environ.get("CONFIG", "/etc/axione-elig-test.ini") |
||||
print(f'Reading the "{cfg_path}" config file') |
||||
cfg = parse_config(cfg_path) |
||||
cfg.debug = True if "DEBUG" in os.environ else False |
||||
if cfg.debug: |
||||
print("===================") |
||||
print("DEBUG_MODE") |
||||
print("No requests will be performed") |
||||
print("We'll inject some dummy data instead") |
||||
print("===================") |
||||
print("") |
||||
return cfg |
||||
|
||||
cfg = load_config() |
||||
app = Flask(__name__) |
||||
|
||||
@app.route("/", methods=['GET']) |
||||
def get_form(): |
||||
return render_template("landing_form.html") |
||||
|
||||
@app.route("/result", methods=['POST']) |
||||
def show_result(): |
||||
pto = escape(request.form['pto']) |
||||
result = parse_response(query_axione_pto(cfg, pto)) |
||||
return render_template("result.html", pto=pto, result=result) |
Loading…
Reference in new issue