When using redirect() in Flask, HTML is written to Console
This question already has an answer here:
Try to use trailing slash in route description, because in opposite case Flask returns 302 redirect by default that can't be handled by your JS code, so try to use this:
@app.route('/login/',methods=['GET', 'POST'])
@app.route('/home/')
instead of this
@app.route('/logIn',methods=['Get', 'Post'])
@app.route('/Home')
I suspect this can be the reason of the issue, but I didn't test it.
PS
1) Do not use such SQL queries:
cursor.execute("SELECT * FROM tbl_user WHERE user_name = '" + _name + "'")
due to possible SQL injections vulnerabilities. Use "prepared" values instead:
cursor.execute("SELECT * FROM tbl_user WHERE user_name = %s", [name])
2) Dont return JSON by this way:
return json.dumps({'message': 'Username or Password not correct'})
Use jsonify
instead:
from flask import jsonify
response = jsonify(message='Username or Password not correct')
链接地址: http://www.djcxy.com/p/12476.html
上一篇: 在烧瓶中后不会呈现新模板