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 = 'user.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 from minibase.blueprints.company.routes import company from minibase.blueprints.geography.routes import geography from minibase.blueprints.sensor.routes import sensor # (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.register_blueprint(company, url_prefix='/company') app.register_blueprint(geography, url_prefix='/geography') app.register_blueprint(sensor, url_prefix='/sensor') # (APP) Returning the initialised app return app