import os
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_login import LoginManager
from flask_migrate import Migrate
from flask_session import Session


app = Flask(__name__)

app.config["SECRET_KEY"] = "secretkey"

basedir = os.path.abspath(os.path.dirname(__file__))
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///" + os.path.join(basedir, "data.sqlite")
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False

SESSION_TYPE = 'filesystem'
app.config.from_object(__name__)
Session(app)

db = SQLAlchemy(app)
Migrate(app, db)


login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = "users.login"


from project.users.views import users
app.register_blueprint(users)

from project.core.views import core
app.register_blueprint(core)

from project.posts.views import posts
app.register_blueprint(posts)