from flask import Flask
from models.models import db, migrate
from web_app.routes.home_routes import home_routes
# from web_app.routes.book_routes import book_routes
# from web_app.routes.twit_routes import twit_routes
# from web_app.routes.twitter_routes import twitter_routes
# from web_app.routes.stats_routes import stats_routes

DATABASE_URL = "sqlite:///boardgame_development.db" # using relative filepath
# SECRET_KEY = "todo customize this secret value via env var"
# DATABASE_URI = "sqlite:////Users/Username/Desktop/your-repo-name/web_app_99.db" # using absolute filepath on Mac (recommended)
# DATABASE_URI = "sqlite:///C:\\Users\\Username\\Desktop\\your-repo-name\\web_app_99.db" # using absolute filepath on Windows (recommended) h/t: https://stackoverflow.com/a/19262231/670433


def create_app():
    app = Flask(__name__)

    # app.config["SECRET_KEY"] = SECRET_KEY
    app.config["SQLALCHEMY_DATABASE_URI"] = DATABASE_URL
    app.config["SQLALCHEMY_TRACK_MODIFICATION"] = DATABASE_URL
    db.init_app(app)
    migrate.init_app(app, db)

    app.register_blueprint(home_routes)
    # app.register_blueprint(book_routes)
    # app.register_blueprint(twit_routes)
    # app.register_blueprint(twitter_routes)
    # app.register_blueprint(stats_routes)
    return app

if __name__ == "__main__":
    my_app = create_app()
    my_app.run(debug=True)            