diff options
author | Ubuntu <ubuntu@ip-172-31-33-141.eu-west-3.compute.internal> | 2023-06-08 00:49:49 +0200 |
---|---|---|
committer | Ubuntu <ubuntu@ip-172-31-33-141.eu-west-3.compute.internal> | 2023-06-08 00:52:14 +0200 |
commit | c17ed59e85f9579e45f1c59d3c95268a1f7d361b (patch) | |
tree | d036277a96cfcf419d4598d5a8c9fff9bf2f9012 | |
parent | global (diff) | |
download | eVinjeta-features.tar eVinjeta-features.tar.gz eVinjeta-features.tar.bz2 eVinjeta-features.tar.lz eVinjeta-features.tar.xz eVinjeta-features.tar.zst eVinjeta-features.zip |
-rw-r--r-- | helpers.py | 2 | ||||
-rw-r--r-- | server.py | 29 |
2 files changed, 7 insertions, 24 deletions
@@ -57,7 +57,7 @@ def veljavnost(registrska: str, drzava: str): } print("\n", payload, "\n------------------\n\n\n") r = requests.post(purl, json=payload, headers=get_headers(), verify=False) - # print("\n"+r.text+"\n------------------\n\n\n") + print("\n"+r.text+"\n------------------\n\n\n") print(r.status_code, r.reason, r.url) return r.json() @@ -73,47 +73,30 @@ def static_from_root(): return send_from_directory(app.static_folder, request.path[1:]) +@app.route("/global", methods=["POST"]) @app.route("/", methods=["POST"]) def apcall(): if "headers" in request.form: setHeaders(request) return "OK" registrska = request.form["registrska"] - try: - ar = aux(registrska) - app.logger.info( - f'Registrska "{registrska}" je veljavna do {ar} ob {niceTime()}' - ) - # discordLog(f"Registrska \"{registrska}\" je veljavna do {ar} ob {niceTime()}") - return render_template("index.html", valid_until=ar, license_plate=registrska) - except Exception as e: - spamDiscord(str(e)) - app.logger.error(f"\nNapaka pri {registrska} ob {niceTime()}") - # discordLog(f"!!!!!!!!!!!!!!!!!!!!!!!!!!!\nNapaka pri {registrska} ob {niceTime()}") - return render_template("failure.html") - - -@app.route("/global", methods=["POST"]) -def apcall_global(): - print(request.form) - registrska = request.form["registrska"] - drzava = request.form["drzava"] + drzava = request.form.get("drzava", "SI") try: ar = aux(registrska, drzava) app.logger.info( f'Registrska "{registrska}" je veljavna do {ar} ob {niceTime()}' ) # discordLog(f"Registrska \"{registrska}\" je veljavna do {ar} ob {niceTime()}") - return render_template( - "index_global.html", valid_until=ar, license_plate=registrska - ) + user_language = request.accept_languages.best_match(["sl", "en"]) + if user_language == "en": + return render_template("index_global.html", valid_until=ar, license_plate=registrska) + return render_template("index.html", valid_until=ar, license_plate=registrska) except Exception as e: spamDiscord(str(e)) app.logger.error(f"\nNapaka pri {registrska} ob {niceTime()}") # discordLog(f"!!!!!!!!!!!!!!!!!!!!!!!!!!!\nNapaka pri {registrska} ob {niceTime()}") return render_template("failure.html") - @app.route("/", methods=["GET"]) def index(): user_language = request.accept_languages.best_match(["sl", "en"]) |