Reputation: 161
This is the JS code, its just meant to send a request to the server then print the response. It sends it fine but I get a 500 error with the response
function UsernameCheck(){
var Username = document.getElementById('username').value;
console.log('Test!');
$.ajax({
type: 'GET',
url: '/CheckUsername',
data:'username='+ Username,
success: function(response) {
console.log(response);
$('#UsernameCheck').html(response);
}
});
}
This is the python code for the request. The prints work fine and it queries the database correctly but the response doesn't work and I am unsure how to fix it
@route('/CheckUsername')
def CheckUsername():
username = request.query.username
print(username)
db = MySQLdb.connect(host=mysqlDom,
user=mysqlUser,
passwd=mysqlPass,
db=mysqlDB)
cur = db.cursor()
cur.execute(SeeIfUserExsistsSQL, [username])
count = cur.rowcount
print(count)
return count
If you need the whole Python code let me know but I believe that is all that is needed
Upvotes: 0
Views: 836
Reputation: 2518
Try to cast explicitly to a string when returning the count. Bottle views need to return specific data types and int is not one of them. See here.
Upvotes: 1