You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1017 B

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("No requests will be performed")
print("We'll inject some dummy data instead")
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)