Nov-12-2020, 08:22 AM
I have blog.py inside my blog folder for Flask application.
blog.py contains:
Meanwhile routes.py inside app folder may import more of these like db, login etc.
So to sum up I would be pleased to know if this is the correct order of the app files running:
*export FLASK_APP=blog.py runs blog.py file inside blog folder
*blog.py runs app variable from __init__ inside app folder
*then who runs routes.py file?
blog.py contains:
from app import appInside blog folder there is app folder and it contains __init__ with the following code:
from flask import Flask from config import Config from flask_sqlalchemy import SQLAlchemy from flask_migrate import Migrate from flask_login import LoginManager app = Flask(__name__) app.config.from_object(Config) login = LoginManager(app) login.login_view = 'login' db = SQLAlchemy(app) migrate = Migrate(app, db) from app import routes, modelsAs I understand from here blog.py takes ONLY app = Flask(__name__) ?
Meanwhile routes.py inside app folder may import more of these like db, login etc.
So to sum up I would be pleased to know if this is the correct order of the app files running:
*export FLASK_APP=blog.py runs blog.py file inside blog folder
*blog.py runs app variable from __init__ inside app folder
*then who runs routes.py file?
#routes.py from flask import render_template, flash, redirect from app import app from app.forms import LoginForm from flask_login import current_user, login_user from app.models import User from flask_login import logout_user from flask_login import login_required from flask import request from werkzeug.urls import url_parse from flask_login import logout_user @app.route('/')Or in general how are the whole files we create from Flask application coming together?