Python Forum

Full Version: Flash is not working in flask
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have written a simple code ,but flash is not showing any message .
Code -
flash('OK. The User ID is x')
return redirect(url_for('about'))
about.html-
<html>
  
  <head>
     <title>Welcome </title>
  </head>
  <body>
  <div class ="container">
     
  {%  with messages = get_flashed_messages() %}
 {% if messages %}
   <ul class =flashes>
   {% for message in messages %}
     <li>{{ message }}</li>
   {% endfor %}
   </ul>
 {% endif %}
{% endwith %}
     </div>
     
  </body>
</html>
are you sure the flash line is executed? Eventually, could you share the entire def?
(Jun-14-2017, 09:44 PM)sahilsiddharth Wrote: [ -> ]
flash('OK. The User ID is x')
return redirect(url_for('about'))

Did you do an from _ import *? Did you also re-define flash?
We can't help unless you show us more code, because what you've got now looks like it should work.
my question here
I am doing a query from Mysql database and then flashing that value on the front-end. But that variable is not appearing

my code here
x=c.execute("SELECT TELLER_ID from TELM where email=(%s)", (email,))

c.close()
conn.close()

flash("The User ID is (%s)", (x) )

---It is showing output as "The User ID is (%s)"