Question: HTML/Python Question: I created a python flask website with a trivia game. At the top of every page, there are 6 links (Home, Leaderboard, Trivia,
HTML/Python Question: I created a python flask website with a trivia game. At the top of every page, there are 6 links (Home, Leaderboard, Trivia, Logout, Login, Sign Up) However, I only want Trivia and Logout to show if the user is logged in, and only want login and sign up to show if the user is logged out. The Home and leaderboard links can stay for both. Below is the HTML and the python code where you could put the answer to this question. Here is the link to my site: http://elizabethsite1.pythonanywhere.com/
HTML Code:
html> <html> <head> <title>Triviatitle> <link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}"> head> <body> <header> <div class="container"> <h1 class="logo">Triviah1> <strong><nav> <ul class="menu"> <li><a href="{{ url_for('home') }}">Homea>li> <li><a href="{{ url_for('leaderboard') }}">Leaderboarda>li> <li><a href="{{ url_for('trivia') }}">Triviaa>li> <li><a href="{{ url_for('dropsession') }}">Log Outa>li> <li><a href="{{ url_for('index') }}">Log Ina>li> <li><a href="{{ url_for('signup') }}">Sign Upa>li> ul> nav>strong> div> header> <div class="container"> {% block content %} {% endblock %} div> body> html> Python Flask
@app.before_request def before_request(): g.user = None if 'user' in session: g.user = session['user']
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
