26 lines
697 B
Python
26 lines
697 B
Python
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"]) |