import os
from flask import Flask
from flask_sqlalchemy import SQLAlchemy


from lyrics import paginas

def create_app():
    app = Flask(__name__)
    app.config.from_prefixed_env()

    app.config['SECRET_KEY'] = 'secret-key-goes-here'
    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///songs.db'

    from .models import db

    db.init_app(app)

    from . import models

    with app.app_context():
        db.create_all()

#    basededatos.init_app(app)

    app.register_blueprint(paginas.bp)

    print(f"Current Environment: {os.getenv('ENVIRONMENT')}")
    print(f"Using Database: {app.config.get('DATABASE')}")

    return app

