You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.8 KiB

from flask import Flask
from flask_session import Session
from flask_sqlalchemy import SQLAlchemy
from flask_bcrypt import Bcrypt
from flask_login import LoginManager
from flask_mail import Mail
from flask_migrate import Migrate
from minibase.config import AppConfig
# (DATABASE) Definition
db = SQLAlchemy()
# (PASSWORD) Hashing Module to save paswords safely
bcrypt = Bcrypt()
# (LOGIN) Login manage plugin configuration
login_manager = LoginManager()
login_manager.login_view = 'users.login' # User management (current_user)
login_manager.login_message_category = 'info' # Boostrap Info Message
# (EMAIL AGENT) Definition
mail = Mail() # So that we can send mails
# (SESSION) Starts the curren flask session
session = Session()
def create_app():
# (APP) Definition
app = Flask(__name__)
# (APP) Configure configuration
app.config.from_object(AppConfig)
# (DATABASE) Initialisation
db.init_app(app)
# (PASSWORD) Initialisation
bcrypt.init_app(app)
# (LOGIN) Initialisation
login_manager.init_app(app)
# (EMAIL AGENT) Initialisation
mail.init_app(app)
# Session for variable manipulation on server side
# (DATABASE) Linking the app and the Database
Migrate(app, db)
# (BLUEPRINTS) Importing the blueprints.
# Include are made here to awoid the Circular import issues
from minibase.blueprints.main.routes import main
from minibase.blueprints.user.routes import user
from minibase.blueprints.errors.routes import errors
# (BLUEPRINTS) Registering the blueprints.
# Giving them theie ulr_prefixes that will define their links on the webBrowser.
app.register_blueprint(main, url_prefix='/')
app.register_blueprint(user, url_prefix='/user')
app.register_blueprint(errors, url_prefix='/errors')
# (APP) Returning the initialised app
return app