from flask import Flask
from flask_bcrypt import Bcrypt
from flask_login import LoginManager
from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager
from flask_sqlalchemy import SQLAlchemy

app = Flask(__name__)
app.config.from_object('config')

db = SQLAlchemy(app)
migrate = Migrate(app, db)
bcrypt = Bcrypt(app)
login_manager = LoginManager(app)
login_manager.login_view = 'users.login'
login_manager.login_message_category = 'info'

from app.models import tables

from app.controllers.users.routes import users
from app.controllers.posts.routes import posts
from app.controllers.main.routes import main
from app.models.tables import admin

app.register_blueprint(users)
app.register_blueprint(posts)
app.register_blueprint(main)

manager = Manager(app)
manager.add_command('db', MigrateCommand)
