i have been learning how use flask framework using tutorial, code in app.py keeps returning error 500, , can't figure out why (my code identical tutorial).
here's app.py:
from flask import flask, render_template, json, request flask.ext.mysql import mysql werkzeug import generate_password_hash, check_password_hash mysql = mysql() app = flask(__name__) # mysql configurations app.config['mysql_database_user'] = 'root' app.config['mysql_database_password'] = 'root' app.config['mysql_database_db'] = 'bucketlist' app.config['mysql_database_host'] = 'localhost' mysql.init_app(app) @app.route('/') def main(): return render_template('index.html') @app.route('/showsignup') def showsignup(): return render_template('signup.html') @app.route('/signup',methods=['post','get']) def signup(): try: _name = request.form['inputname'] _email = request.form['inputemail'] _password = request.form['inputpassword'] # validate received values if _name , _email , _password: # good, let's call mysql conn = mysql.connect() cursor = conn.cursor() _hashed_password = generate_password_hash(_password) cursor.callproc('sp_createuser',(_name,_email,_hashed_password)) data = cursor.fetchall() if len(data) 0: conn.commit() return json.dumps({'message':'user created !'}) else: return json.dumps({'error':str(data[0])}) else: return json.dumps({'html':'<span>enter required fields</span>'}) except exception e: return json.dumps({'error':str(e)}) return traceback.format_exc() finally: cursor.close() conn.close() if __name__ == "__main__": app.run(port=5002)
it's signup system.
a 500 error means there error in python instead when run try withh app.run(port=5002,debug=true)
wont solve problem ... should tell whats going on
Comments
Post a Comment