Esempio n. 1
0
def create_app():
    app = Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get(
        'DATABASE_URL', 'sqlite:///yume.db')
    app.config['TEMPLATES_AUTO_RELOAD'] = True
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

    try:
        with open('.secret_key', 'rb') as f:
            app.secret_key = f.read()
    except FileNotFoundError:
        app.secret_key = os.urandom(64)
        f = open('.secret_key', 'wb')
        f.write(app.secret_key)
        f.close()

    app.register_blueprint(api)
    app.register_blueprint(game)

    db.app = app
    db.init_app(app)

    babel.app = app
    babel.init_app(app)

    app.config.update(
        CELERY_BROKER_URL=os.environ.get(
            'CELERY_BROKER_URL', 'sqla+sqlite:///yume_broker.db'),
        CELERY_RESULT_BACKEND=os.environ.get(
            'CELERY_RESULT_BACKEND', 'db+sqlite:///yume_reuslt.db'))
    return app
Esempio n. 2
0
def create_app():
    app = Flask(__name__)
    app.config['SQLALCHEMY_DATABASE_URI'] = os.environ.get(
        'DATABASE_URL', 'sqlite:///yume.db')
    app.config['TEMPLATES_AUTO_RELOAD'] = True
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    app.secret_key = b'\xc2o\x81?u+\x14j%\x99\xc5\xa6\x83\x06`\xfch$\n"a0\x96\x8c'  # noqa
    app.register_blueprint(api)
    app.register_blueprint(game)

    db.app = app
    db.init_app(app)

    babel.app = app
    babel.init_app(app)

    app.config.update(
        CELERY_BROKER_URL=os.environ.get('REDIS_URL',
                                         'redis://localhost:6379'),
        CELERY_RESULT_BACKEND=os.environ.get('REDIS_URL',
                                             'redis://localhost:6379'))
    return app