Project 4: Movie Watchlist: Add user logouts to the portfolio project (+9, -1)

routes.py (+8, -0)

From: curriculum/section14/lectures/18_user_logout_in_flask_app/start/movie_library/routes.py

To: curriculum/section14/lectures/18_user_logout_in_flask_app/end/movie_library/routes.py

            
            index 90e18df..6e73cf1 100644
--- a/curriculum/section14/lectures/18_user_logout_in_flask_app/start/movie_library/routes.py
+++ b/curriculum/section14/lectures/18_user_logout_in_flask_app/end/movie_library/routes.py
@@ -100,6 +100,14 @@ def login():
     return render_template("login.html", title="Movies Watchlist - Login", form=form)
 
 
+@pages.route("/logout")
+def logout():
+    del session["email"]
+    del session["user_id"]
+
+    return redirect(url_for(".login"))
+
+
 @pages.route("/add", methods=["GET", "POST"])
 @login_required
 def add_movie():
        

nav.html (+1, -1)

From: curriculum/section14/lectures/18_user_logout_in_flask_app/start/movie_library/templates/macros/nav.html

To: curriculum/section14/lectures/18_user_logout_in_flask_app/end/movie_library/templates/macros/nav.html

            
            index a7a9ece..f395449 100644
--- a/curriculum/section14/lectures/18_user_logout_in_flask_app/start/movie_library/templates/macros/nav.html
+++ b/curriculum/section14/lectures/18_user_logout_in_flask_app/end/movie_library/templates/macros/nav.html
@@ -30,7 +30,7 @@
                     <span class="nav__item">Movies</span>
                 </a>
                 <a
-                    href="#"
+                    href="{{ url_for('pages.logout') }}"
                     class="nav__link"
                 >
                     <span class="nav__item">Log out</span>