How does "app = Flask(name)" works exactly in a flask application? I a learning Flask and trying to understand every line of the code and its' purpose. Could anyone please clarify the significance of the above statement.
Asked
Active
Viewed 4,355 times
1 Answers
2
Slightly modified from the tutorial's explanation here: https://flask.palletsprojects.com/en/1.1.x/tutorial/factory/
app = Flask(__name__) # creates the Flask instance.
__name__
is the name of the current Python module. The app needs to know where it’s located to set up some paths, and__name__
is a convenient way to tell it that.
In other words: Flask
is a class, as seen here: https://github.com/pallets/flask/blob/master/src/flask/app.py#L87, and you're creating one instance of that class.

mechanical_meat
- 163,903
- 24
- 228
- 223