Carson Evans Carson Evans - 1 month ago 13
Python Question

Flask parameter converters 'int' object is not callable

I'm having issues using the flask parameter converter in even a simple app. No matter what I do I keep getting

TypeError: 'int' object is not callable


from flask import Flask

app = Flask(__name__)

@app.route('/<int:number>')
def number(number):
return number

app.run()


If I remove the
int
part of the parameter, it works fine. But I need it as an integer for later use.

Answer

You can't return a number from a Flask view.

return str(number)

Python will not automatically cast the int to a string.

Comments