コード例 #1
0
ファイル: app_maker.py プロジェクト: ncc0706/flask-demo
def register_extensions(app):
    """Register Flask extensions."""

    logger.init_app(app, 'flask.log')
    db.init_app(app)
    migrate.init_app(app, db)
    cache.init_app(app)
    admin.init_app(app)
    # KeyError: 'CELERY_BROKER_URL'
    # celery.init_app(app)

    bcrypt.init_app(app)
    csrf_protect.init_app(app)
    login_manager.init_app(app)
    debug_toolbar.init_app(app)
    webpack.init_app(app)

    return None
コード例 #2
0
ファイル: app.py プロジェクト: suttacentral/suttacentral
def register_extensions(app):
    cache.init_app(app, config={'CACHE_TYPE': 'simple'})
コード例 #3
0
#!/usr/bin/env python
import os
import yaml
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
from flask_swagger_ui import get_swaggerui_blueprint
from common.extensions import cache

app = Flask(__name__)
cache.init_app(app)

config_obj = yaml.load(open('config.yaml'), Loader=yaml.Loader)

# override the environment variables
database_url = os.getenv('SQLALCHEMY_DATABASE_URI')
app.config['SQLALCHEMY_DATABASE_URI'] = config_obj[
    'SQLALCHEMY_DATABASE_URI'] if database_url is None else database_url

app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

db = SQLAlchemy(app)

migrate = Migrate(app, db)

### swagger specific ###
SWAGGER_URL = '/'
API_URL = '/static/swagger.json'
SWAGGERUI_BLUEPRINT = get_swaggerui_blueprint(SWAGGER_URL,
                                              API_URL,
                                              config={'app_name': "Flask API"})
コード例 #4
0
def register_extensions(app):
    cache.init_app(app, config={'CACHE_TYPE': 'simple'})
コード例 #5
0
from flask import Flask
from flask_cors import CORS
from common.extensions import cache

from routes.routes import routes_list

app = Flask(__name__)
cors = CORS(app)
cache.init_app(app, config={'CACHE_TYPE': 'simple'})

app.config['CORS_HEADERS'] = 'Content-Type'

for (url, method, allowed_methods) in routes_list:
    app.add_url_rule(url, view_func=method, methods=allowed_methods)

if __name__ == '__main__':
    app.run('0.0.0.0', port=5000, debug=False)