how to add sweet alert in flask? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula gr√°tis
+ 1

how to add sweet alert in flask?

i try to add sweet alert using flashing message it is not working well so i try to add sweet alert using js sweet alert is working well but data is not saving else error message will display for all possibilities. i i'm confused now how to add sweet alert using js or flask flashing methods? help me please

5th Mar 2024, 6:00 AM
Jayashree M
18 Respostas
+ 1
k i'll try it
5th Mar 2024, 11:21 AM
Jayashree M
0
i try is already on error message is working data is not saving so posted question here
5th Mar 2024, 9:50 AM
Jayashree M
0
maybe try posting what error message are you getting.
5th Mar 2024, 9:52 AM
Bob_Li
Bob_Li - avatar
0
if request.method == 'POST': country = request.form.get('country') #getting form data admin_instance = Country() #mysql data is stored in separate python file and this is the instance of that account = admin_instance.get_country_by_name(country) #compare if the entered already if account: flash("Already exits",'error') #if country already exist then display error return redirect('/AddCountry') else: flash("Successfully Submitted", 'success') #else success add_country = admin_instance.add_country(country, date_now) #saving data to mysql i got only error as message for every input and data is not saving to mysql i have written comments( #) as that u can understand above code is flask
5th Mar 2024, 10:15 AM
Jayashree M
0
I am confused. are you using js comments '//' in a .py python file? shouldn't those '//' supposed to be '#' instead?
5th Mar 2024, 10:23 AM
Bob_Li
Bob_Li - avatar
0
sorry yes it have return wrong right now i have edited please help me
5th Mar 2024, 10:37 AM
Jayashree M
0
are you sure your db is running, properly initiated and accessible?
5th Mar 2024, 10:50 AM
Bob_Li
Bob_Li - avatar
0
yes working perfectly i just separated mysql and route files ,it working
5th Mar 2024, 10:55 AM
Jayashree M
0
what's the error message you're getting?
5th Mar 2024, 10:57 AM
Bob_Li
Bob_Li - avatar
0
sweet alert not working i have written sweetalert.html and flash("Already exits",'error')
5th Mar 2024, 10:59 AM
Jayashree M
0
is your sweetalert cdn valid? did you set up the template properly?
5th Mar 2024, 11:01 AM
Bob_Li
Bob_Li - avatar
0
yes same as given in this github code https://github.com/ondiekelijah/SweetAlert-Js-with-Flask
5th Mar 2024, 11:03 AM
Jayashree M
0
did you clone the repo or typed it manually? perhaps you have a typo... it's hard to say, blind-guessing this way...
5th Mar 2024, 11:07 AM
Bob_Li
Bob_Li - avatar
0
typed it manually
5th Mar 2024, 11:12 AM
Jayashree M
0
recheck the sweetalert parts. flask is not finding it. Did you use the template method or inline method? maybe your filepath is wrong
5th Mar 2024, 11:15 AM
Bob_Li
Bob_Li - avatar
0
How to work on it like pro
6th Mar 2024, 6:20 AM
Mayank Singh
Mayank Singh - avatar
0
How can I add a background image in html
6th Mar 2024, 4:07 PM
Chritchwell Hamang'onze
Chritchwell Hamang'onze - avatar