Ejemplo n.º 1
0
def initialize_app(flask_app):
    """Apply application configuration.

    Load configuration to Flask object and apply configuration to it
        :param flask_app: Flask application to configure
        :type flask_app: Flask
    """
    configure_app(flask_app)

    # Fix to handle properly X-Forwarded-Proto header
    # from werkzeug.contrib.fixers import ProxyFix
    flask_app.wsgi_app = ProxyFix(flask_app.wsgi_app)

    # Define base_url for the app
    blueprint = Blueprint('api', __name__, url_prefix=settings.API["base_url"])
    api.init_app(blueprint)
    api.add_namespace(admin_ns)
    api.add_namespace(sensors_ns)
    api.add_namespace(phone_ns)

    # Define base_url from swaggerui resources (js, css...)
    api_doc = flask_restx.apidoc.apidoc
    api_doc.url_prefix = settings.API["base_url"] + "/doc"

    flask_app.register_blueprint(blueprint)
Ejemplo n.º 2
0
def initialize_app(flask_app):
    """Apply application configuration.

    Load configuration to Flask object and apply configuration to it
        :param flask_app: Flask application to configure
        :type flask_app: Flask
    """
    configure_app(flask_app)
    flask_app.wsgi_app = ProxyFix(flask_app.wsgi_app)

    blueprint = Blueprint('api',
                          __name__,
                          url_prefix=settings.API["context_root"])
    api.init_app(blueprint)

    api.add_namespace(equipements_namespace)
    #api.add_namespace(servers_namespace)
    api.add_namespace(recorder_namespace)
    api.add_namespace(monitoring_namespace)

    api_doc = flask_restx.apidoc.apidoc
    api_doc.url_prefix = settings.API["context_root"] + "/doc"
    flask_app.register_blueprint(blueprint)
    requests.urllib3.disable_warnings()