This commit is contained in:
hubobel 2026-06-20 16:00:31 +02:00
parent d6e6f01329
commit af9e2fc138
3 changed files with 178 additions and 0 deletions

92
app.py Normal file
View file

@ -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
)

66
templates/index.html Normal file
View file

@ -0,0 +1,66 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<title>ING Auswertung</title>
</head>
<body>
<h1>ING Auswertung</h1>
<hr>
<h2>Kontostand</h2>
<form action="/run/balance" method="post">
<button type="submit">
balance.py starten
</button>
</form>
<hr>
<h2>Transaktionen</h2>
<form action="/run/transactions" method="post">
Jahr:
<input type="text"
name="year"
placeholder="2026">
KW:
<input type="text"
name="week"
placeholder="25">
<button type="submit">
transactions.py starten
</button>
</form>
<hr>
<h2>Kategorisierung</h2>
<form action="/run/categorize" method="post">
Jahr:
<input type="text"
name="year"
placeholder="2026">
KW:
<input type="text"
name="week"
placeholder="25">
<button type="submit">
categorize_transactions.py starten
</button>
</form>
</body>
</html>

20
templates/result.html Normal file
View file

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<title>{{ title }}</title>
</head>
<body>
<h1>{{ title }}</h1>
<a href="/">Zurück</a>
<hr>
<pre>
{{ output }}
</pre>
</body>
</html>