From 090a2ed3ce9d1ff69063d43359d2d79448d0e28d Mon Sep 17 00:00:00 2001
From: Fudgerboy <91767657+Fudgerboy@users.noreply.github.com>
Date: Thu, 1 Aug 2024 09:45:10 +0000
Subject: Thu, Aug 1, 2024, 2:45 AM -07:00

---
 wk9/lect/cookies/app.py               | 6 ++++--
 wk9/lect/cookies/templates/index.html | 4 ++--
 2 files changed, 6 insertions(+), 4 deletions(-)

(limited to 'wk9/lect')

diff --git a/wk9/lect/cookies/app.py b/wk9/lect/cookies/app.py
index bc7ab19..74b7964 100644
--- a/wk9/lect/cookies/app.py
+++ b/wk9/lect/cookies/app.py
@@ -1,4 +1,5 @@
 from flask import Flask, render_template, request, session
+from flask_session import Session
 
 app = Flask(__name__)
 
@@ -8,11 +9,12 @@ Session(app)
 
 @app.route("/")
 def index():
-    return render_template("index.html")
+    return render_template("index.html", name=session.get("name"))
 
 
 @app.route("/login")
 def login():
     if request.method == "POST":
-        session
+        session["name"] = request.form.get("name")
+        return redirect("/")
     return render_template("login.html")
diff --git a/wk9/lect/cookies/templates/index.html b/wk9/lect/cookies/templates/index.html
index f902b58..3f08ec1 100644
--- a/wk9/lect/cookies/templates/index.html
+++ b/wk9/lect/cookies/templates/index.html
@@ -4,11 +4,11 @@
 
         {% if name %}
 
-            You are logged in as {{ name }}.
+            You are logged in as {{ name }}. <a href="/logout">Log out</a>.
 
         {% else %}
 
-            You are not logged in.
+            You are not logged in. <a href="/login">Log in</a>.
 
         {% endif %}
 
-- 
cgit v1.2.3