diff --git a/app.py b/app.py new file mode 100644 index 0000000..1850b83 --- /dev/null +++ b/app.py @@ -0,0 +1,92 @@ +from pathlib import Path +from flask import Flask, render_template, request +import subprocess +import sys + +app = Flask(__name__) + +BASE_DIR = Path(__file__).parent + + +@app.route("/") +def index(): + return render_template("index.html") + + +@app.route("/run/balance", methods=["POST"]) +def run_balance(): + + result = subprocess.run( + [sys.executable, str(BASE_DIR / "balance.py")], + capture_output=True, + text=True + ) + + return render_template( + "result.html", + title="balance.py", + output=result.stdout + result.stderr + ) + + +@app.route("/run/transactions", methods=["POST"]) +def run_transactions(): + + year = request.form.get("year", "").strip() + week = request.form.get("week", "").strip() + + command = [ + sys.executable, + str(BASE_DIR / "transactions.py") + ] + + if year and week: + command.extend([year, week]) + + result = subprocess.run( + command, + capture_output=True, + text=True + ) + + return render_template( + "result.html", + title="transactions.py", + output=result.stdout + result.stderr + ) + + +@app.route("/run/categorize", methods=["POST"]) +def run_categorize(): + + year = request.form.get("year", "").strip() + week = request.form.get("week", "").strip() + + command = [ + sys.executable, + str(BASE_DIR / "categorize_transactions.py") + ] + + if year and week: + command.extend([year, week]) + + result = subprocess.run( + command, + capture_output=True, + text=True + ) + + return render_template( + "result.html", + title="categorize_transactions.py", + output=result.stdout + result.stderr + ) + + +if __name__ == "__main__": + + app.run( + host="0.0.0.0", + port=5000, + debug=True + ) \ No newline at end of file diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..1c1c49b --- /dev/null +++ b/templates/index.html @@ -0,0 +1,66 @@ + + + + + ING Auswertung + + + +

ING Auswertung

+ +
+ +

Kontostand

+ +
+ +
+ +
+ +

Transaktionen

+ +
+ + Jahr: + + + KW: + + + + +
+ +
+ +

Kategorisierung

+ +
+ + Jahr: + + + KW: + + + + +
+ + + \ No newline at end of file diff --git a/templates/result.html b/templates/result.html new file mode 100644 index 0000000..2ef5845 --- /dev/null +++ b/templates/result.html @@ -0,0 +1,20 @@ + + + + + {{ title }} + + + +

{{ title }}

+ +Zurück + +
+ +
+{{ output }}
+
+ + + \ No newline at end of file