from flask import Flask
from flask_cors import CORS, cross_origin
import os


def create_app():
    SECRET_KEY = os.urandom(32)
    app = Flask(__name__)
    CORS(app)
    app.config['SECRET_KEY'] = SECRET_KEY

    from backstage.collections.routes import collections_app
    from backstage.editor.routes import editor_app
    from backstage.home.routes import home_app
    from backstage.room_planner.routes import room_planner_app
    from backstage.blogs.routes import blogs_app
    from backstage.store_locations.routes import store_locations_app
    from backstage.upload.routes import upload_app

    CORS(upload_app)
    app.register_blueprint(collections_app)
    app.register_blueprint(editor_app)
    app.register_blueprint(home_app)
    app.register_blueprint(blogs_app)
    app.register_blueprint(room_planner_app)
    app.register_blueprint(store_locations_app)
    app.register_blueprint(upload_app)

    from models.contents.routes import contents_app
    from models.manages.routes import manages_app
    #from models.store_locations.routes import store_locations_app
    from models.statics.routes import statics_app
    
    app.register_blueprint(contents_app)
    app.register_blueprint(manages_app)
    #app.register_blueprint(store_locations_app)
    app.register_blueprint(statics_app)
    
    
    return app
