Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flask: "from app import app"?

I'm following this tutorial to make a basic Flask app: and I don't understand the line of code in app/view.py that says from app import app. In that line, what do both of the app refer to? Do they both refer to the same thing?

Note: I know that there is a folder called app, and that there is an object

app = Flask(__ name__) in __ init__.py 

if that helps...

like image 261
codersun3 Avatar asked Mar 16 '23 16:03

codersun3


1 Answers

It means:

from package app import object app

So the first appis the name of the package (which is a folder with a __init__.py file inside) and the second is the name of the imported object from that package. See the answers to this question for more info.

like image 83
doru Avatar answered Mar 29 '23 01:03

doru