Home > database >  app = Flask(__name__) TypeError: 'module' object is not callable
app = Flask(__name__) TypeError: 'module' object is not callable

Time:09-22

When I run the following code, I get TypeError: 'module' object is not callable instead of a running application.

import flask as Flask

app = Flask(__name__)

@app.route('/')
def index():
    return "Hello World"

if __name__ == '__main__':
    app.run(debug = True)
  app = Flask(__name__)
TypeError: 'module' object is not callable

CodePudding user response:

You have aliased the module instead of importing the Flask class.

Try instead

from flask import Flask

CodePudding user response:

Flask.Flask(__name__) worked

Thanks @Wondercricket from the comment section.

  • Related