feat: add home und login function
This commit is contained in:
1 parent
535405cf99
commit
92807e857a
6 files changed
+200
-22
No files matched your search
@@ -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"])
|
||||
Reference in new issue
Block a user