For the finance website homepage, I want to render index.html differently based on the previous url. For example, if I logged in I want to render a panel saying 'logged in', but if I registered I want the panel to say 'registered or if I bought some stocks I want the panel to say 'Bought'. How do I go about implementing this functionality using Jinja so that I can use just one html template instead of several? Any help would be appreciated. In case my description wasn't clear it is something like this: http://pset7.cs50.net/
2 Answers
Inside the function for the respective routes you can just call the function "flash(message)" before the "return redirect()" function, where "message" is the message you want to display. for example:
flash ("Bought")
return redirect(url_for("index"))
How about if you create a new session
key, like session['action'] = 'Bought'
that gets set in the appropriate route?
-
-
1Just like
session['user_id']
in the login route. egsession['action'] = 'Bought'
. Commented Apr 18, 2017 at 14:25