furtka/webinstaller/app.py
Daniel Maksymilian Syrnicki 852efdb0ed
Some checks failed
CI / lint (push) Failing after 36s
CI / test (push) Failing after 1s
CI / validate-json (push) Failing after 2s
CI / markdown-links (push) Failing after 1s
ci: add Forgejo Actions workflow with ruff, pytest, JSON + link checks
- .forgejo/workflows/ci.yml: four jobs (lint, test, validate-json,
  markdown-links) running on push to main and on pull requests
- pyproject.toml: project metadata, flask dep, dev extras (ruff, pytest),
  ruff config (E/F/I/W/B/UP rulesets, 100-char lines, py311 target),
  pytest config (pythonpath=webinstaller so tests can import drives)
- tests/test_drives.py: 11 unit tests covering parse_size_gb (TB/GB/MB,
  European comma decimal, empty input, unknown units), drive type
  scoring (nvme/ssd/hdd), size scoring bands, and score_device summing
- .gitignore: ignore .pytest_cache, *.egg-info, .ruff_cache
- webinstaller/drives.py: refactor subprocess.run to capture_output
  kwarg (ruff UP022) — drops four lines, same behavior
- webinstaller/app.py: ruff-sorted imports (isort)

All checks pass locally: ruff check + format, pytest 11/11, JSON valid.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-13 20:24:05 +02:00

47 lines
1.2 KiB
Python

from drives import list_scored_devices
from flask import Flask, redirect, render_template, request, url_for
app = Flask(__name__)
settings = {
# Step 1
"hostname": "furtka",
"username": "",
"password": "",
"password2": "",
"backend": False,
"backend_adress": "127.0.0.1",
"language": "en",
# devices
"boot_drive_uuid": "",
}
@app.route("/")
def home():
return "Hello World"
@app.route("/install/step1", methods=["GET", "POST"])
def install_step_1():
if request.method == "POST":
settings["hostname"] = request.form["hostname"]
return redirect(url_for("install_step_2"))
return render_template("install/step1.html")
@app.route("/install/step2", methods=["GET", "POST"])
def install_step_2():
if request.method == "POST":
settings["boot_drive_uuid"] = request.form["boot_drive_uuid"]
return redirect(url_for("install_overview"))
return render_template("install/step2.html", drives=list_scored_devices())
@app.route("/install/overview")
def install_overview():
return render_template("install/overview.html", settings=settings)
if __name__ == "__main__":
app.run(debug=True, port=5000)