feat(users): configures session with sqlalchemy
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
from flask import Flask
|
from flask import Flask
|
||||||
|
from flask_session import Session
|
||||||
|
|
||||||
from config import Config
|
from config import Config
|
||||||
from app.extensions import db
|
from app.extensions import db
|
||||||
@@ -7,8 +8,10 @@ from app.utils import DBUtils, ROUTES
|
|||||||
def create_app(config_class=Config):
|
def create_app(config_class=Config):
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.config.from_object(config_class)
|
app.config.from_object(config_class)
|
||||||
|
app.config['SESSION_SQLALCHEMY'] = db
|
||||||
|
|
||||||
db.init_app(app)
|
db.init_app(app)
|
||||||
|
|
||||||
@app.context_processor
|
@app.context_processor
|
||||||
def inject_routes():
|
def inject_routes():
|
||||||
"""Inject ROUTES dictionary into all templates."""
|
"""Inject ROUTES dictionary into all templates."""
|
||||||
@@ -19,7 +22,7 @@ def create_app(config_class=Config):
|
|||||||
DBUtils.setup_db(app)
|
DBUtils.setup_db(app)
|
||||||
|
|
||||||
# Initialize Flask extensions here
|
# Initialize Flask extensions here
|
||||||
|
Session(app)
|
||||||
# Register blueprints here
|
# Register blueprints here
|
||||||
from app.main import bp as main_bp
|
from app.main import bp as main_bp
|
||||||
app.register_blueprint(main_bp)
|
app.register_blueprint(main_bp)
|
||||||
|
|||||||
@@ -8,3 +8,4 @@ class Config:
|
|||||||
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URI')\
|
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URI')\
|
||||||
or 'sqlite:///' + os.path.join(basedir, 'instance\\adogapet.db')
|
or 'sqlite:///' + os.path.join(basedir, 'instance\\adogapet.db')
|
||||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||||
|
SESSION_TYPE = 'sqlalchemy'
|
||||||
Reference in New Issue
Block a user