S
S
sergey199408082017-05-18 10:19:55
Flask
sergey19940808, 2017-05-18 10:19:55

Flask, how to correctly split a project into layouts using blueprint?

I want to divide the project into layouts.
Now the structure is:

Проект/
__init__.py
        Приложение/
            __init__.py
           templates/
           forms.py
           views.py


The project-level __init__.py file contains the following content:
from flask import Flask
    from flask_login import LoginManager
    from flask_mail import Mail
    from flask_migrate import Migrate, MigrateCommand
    from flask_script import Manager
    from flask_sqlalchemy import SQLAlchemy
    from flask_bcrypt import Bcrypt
    from auth import auth

# инициализация приложений
    app = Flask(__name__)
    app.register_blueprint(auth, url_prefix='/')
    app.config.from_object('config')
    db = SQLAlchemy(app)
    lm = LoginManager(app)
    lm.login_view = 'login'
    lm.login_message = 'Пожалуйста введите свои данные для входа на сайт, либо 
    зарегистрируйтесь'
    migrate = Migrate(app, db)
    manager = Manager(app)
    manager.add_command('db', MigrateCommand)
    mail = Mail(app)
    bcrypt = Bcrypt(app)


In the __init__.py file of the application level, something like this (in others, the position changes based on the names of the applications):
from flask import Blueprint

    auth = Blueprint('auth', __name__, template_folder='./templates')


I check through url_map through the terminal:
from __init__ import app
    app.url_map
    Map([<Rule '/static/<filename>' (GET, OPTIONS, HEAD) -> static>])


Why is the layout not connected??

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question