A doc of Flask, although it uses in its examples, it alerts to the bottom of the page about the bad practice of using circular imports.
Another thing that bothers me is to create "global objects" within a __init__.py
file.
What would be the other solution?
File __init__.py
of the main module, ie the main application folder:
from flask import Flask
app = Flask(__name__)
import yourapplication.views
The views.py file (The application view):
from yourapplication import app
@app.route('/')
def index():
return 'Hello World!'
The structure of the project:
/yourapplication
setup.py
/yourapplication
__init__.py
views.py
/static
style.css
/templates
layout.html
index.html
login.html
...
Sample Code Credits: link