2

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/

4

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"))
1
  • So every import from flask has its use – Michael Zhang Jun 19 '17 at 0:28
2

How about if you create a new session key, like session['action'] = 'Bought' that gets set in the appropriate route?

2
  • How do you create a new session key? – user34304 Apr 18 '17 at 14:11
  • 1
    Just like session['user_id'] in the login route. eg session['action'] = 'Bought'. – DinoCoderSaurus Apr 18 '17 at 14:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .