def apiRegister(): data = request.get_json() print(data) if 'username' in data: print('yesss') if register_user(data): return jsonify({'status': 'registered', 'message': 'new user successfully registered'}) return jsonify({'status': 'failed', 'message': 'An error occured during the registration process'})
def postRegister(): if request.method == 'POST' and check_keys(request.form) and register_user( request.form): return render_template('postRegister.html', error=None) return render_template('errorRegister.html', error=None)
'username': '******', 'city': 'test', 'address': 'test', 'password': '******' } admin = { 'firstname': 'admin', 'lastname': 'admin', 'email': 'admin', 'username': '******', 'city': 'admin', 'address': 'admin', 'password': '******' } register_user(user) register_user(admin) sql = "update users set Role = \'ADMIN\' WHERE FirstName = \'admin\'" cursor.execute(sql) conn.commit() except MySQLdb.Error as e: print('error {}: {}'.format(e.args[0], e.args[1])) # Error code number, description sys.exit( 1) # Raise a SystemExit exception for cleanup, but honor finally-block finally: print('finally...') if conn: # Always close the connection