feat: add home und login function

This commit is contained in:
robin committed 2026-10-31 20:16:34 +01:00
1 parent 535405cf99
commit 92807e857a
6 files changed
+200 -22

No files matched your search

+3 -17
View File
@@ -1,23 +1,9 @@
from flask import Flask, render_template, request, redirect, url_for, session
from flask import Flask
from routes import bp
app = Flask(__name__)
app.secret_key = "secret-key-ultra-pro-max-123"
@app.route("/", methods=["GET", "POST"])
def index():
if request.method == "POST":
session["name"] = request.form["name"].strip()
return redirect(url_for("test"))
return render_template("index.html")
@app.route("/test")
def test():
if "name" not in session:
return redirect(url_for("index"))
return render_template("test.html", name=session["name"])
app.register_blueprint(bp)
if __name__ == "__main__":
app.run(debug=True)
+26
View File
@@ -0,0 +1,26 @@
from flask import Blueprint, render_template, request, redirect, url_for, session
bp = Blueprint("main", __name__)
@bp.route("/login")
def login():
if "name" in session:
return redirect(url_for("main.index"))
return render_template("login.html")
@bp.route("/", methods=["GET", "POST"])
def index():
if request.method == "POST":
session["name"] = request.form["name"].strip()
if "name" not in session:
return redirect(url_for("main.login"))
return render_template("index.html")
@bp.route("/test")
def test():
if "name" not in session:
return redirect(url_for("main.index"))
return render_template("test.html", name=session["name"])
+131
View File
@@ -0,0 +1,131 @@
:root {
--bg: #ffffff;
--surface: #f4f5f7;
--text: #1b1e23;
--muted: #5f6672;
--border: #d8dbe0;
--accent: #2563eb;
--accent-text: #ffffff;
}
@media (prefers-color-scheme: dark) {
:root {
--bg: #14161a;
--surface: #1d2025;
--text: #e6e8eb;
--muted: #9aa1ac;
--border: #2f343b;
--accent: #5b8def;
--accent-text: #0e1116;
}
}
* { box-sizing: border-box; }
body {
margin: 0;
background: var(--bg);
color: var(--text);
font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
line-height: 1.5;
}
header {
background: var(--surface);
border-bottom: 1px solid var(--border);
}
.header-inner {
max-width: 720px;
margin: 0 auto;
padding: .75rem 1rem;
display: flex;
align-items: center;
justify-content: space-between;
gap: 1rem;
}
.brand {
font-weight: 600;
font-size: 1.1rem;
color: var(--text);
text-decoration: none;
}
.user { color: var(--muted); font-size: .9rem; }
main {
max-width: 720px;
margin: 0 auto;
padding: 1.5rem 1rem 3rem;
}
a { color: var(--accent); }
input, textarea, select, button {
font: inherit;
color: var(--text);
background: var(--surface);
border: 1px solid var(--border);
border-radius: 6px;
padding: .5rem .75rem;
}
button {
background: var(--accent);
color: var(--accent-text);
border-color: var(--accent);
cursor: pointer;
}
button:hover {
filter: brightness(1.1);
}
audio { width: 100%; }
.login-wrap {
display: grid;
place-items: center;
min-height: 70vh; /* Fallback für ältere Browser */
min-height: 70dvh; /* berücksichtigt die Adressleiste auf dem Handy */
}
.login-card {
width: 100%;
max-width: 22rem;
padding: 1.5rem;
background: var(--surface);
border: 1px solid var(--border);
border-radius: 10px;
}
.login-card h1 {
margin: 0 0 .25rem;
font-size: 1.4rem;
}
.login-hint {
margin: 0 0 1.25rem;
color: var(--muted);
font-size: .95rem;
}
.login-card label {
display: block;
margin-bottom: .25rem;
font-size: .9rem;
color: var(--muted);
}
.login-card input,
.login-card button {
width: 100%;
font-size: 1rem; /* mind. 16px, sonst zoomt iOS beim Fokussieren hinein */
min-height: 2.75rem; /* gut mit dem Daumen treffbar */
}
.login-card button {
margin-top: 1rem;
}
+18 -5
View File
@@ -1,11 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<!doctype html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AudioRating</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="color-scheme" content="light dark">
<title>{% block title %}AudioRating{% endblock %}</title>
<link rel="stylesheet" href="{{ url_for('static', filename='style/style.css') }}">
</head>
<body>
<header>
<div class="header-inner">
<a class="brand" href="{{ url_for('main.index') }}">AudioRating</a>
{% if session.get('name') %}
<span class="user">Angemeldet als {{ session['name'] }}</span>
{% endif %}
</div>
</header>
<main>
{% block content %}{% endblock %}
</main>
</body>
</html>
+4
View File
@@ -1,4 +1,8 @@
{% extends "base.html" %}
{% block content %}
<form action="{{ url_for('main.test') }}" method="get">
<button type="submit">Test starten</button>
</form>
{% endblock %}
+18
View File
@@ -0,0 +1,18 @@
{% extends "base.html" %}
{% block content %}
<div class="login-wrap">
<div class="login-card">
<h1>Willkommen</h1>
<p class="login-hint">Bitte gib deinen Namen ein, um den Test zu starten.</p>
<form method="post" action="{{ url_for('main.index') }}">
<label for="name">Name</label>
<input id="name" name="name" type="text" autocomplete="name" required autofocus>
<button type="submit">Starten</button>
</form>
</div>
</div>
{% endblock %}