Carson Evans Carson Evans - 1 year ago 142
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__)

def number(number):
return number

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

Answer Source

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

return str(number)

Python will not automatically cast the int to a string.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download