Python Forum
Flash is not working in flask
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Flash is not working in flask
#1
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>
Reply
#2
are you sure the flash line is executed? Eventually, could you share the entire def?
Reply
#3
(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.
Reply
#4
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)"

User has been warned for this post. Reason: No BBcode, Creating new threads unnecessarily
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  code not working when executed from flask app ThomasDC 1 876 Jul-18-2023, 07:16 AM
Last Post: ThomasDC
  Help with getting a led to flash. corsasri 10 4,108 Aug-06-2020, 05:14 PM
Last Post: DPaul

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020