当前位置: 首页>>代码示例>>Python>>正文


Python fixers.ProxyFix方法代码示例

本文整理汇总了Python中werkzeug.contrib.fixers.ProxyFix方法的典型用法代码示例。如果您正苦于以下问题:Python fixers.ProxyFix方法的具体用法?Python fixers.ProxyFix怎么用?Python fixers.ProxyFix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在werkzeug.contrib.fixers的用法示例。


在下文中一共展示了fixers.ProxyFix方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: init_app

# 需要导入模块: from werkzeug.contrib import fixers [as 别名]
# 或者: from werkzeug.contrib.fixers import ProxyFix [as 别名]
def init_app(cls, app):
        Config.init_app(app)

        if app.config.get('ENABLE_PROXYFIX'):
            # handle proxy server headers
            from werkzeug.contrib.fixers import ProxyFix
            app.wsgi_app = ProxyFix(app.wsgi_app)

        if app.config.get('VERBOSE_SQLALCHEMY'):
            import logging
            from logging import StreamHandler
            stream_handler = StreamHandler()
            stream_handler.setLevel(logging.INFO)
            sql_logger = logging.getLogger('sqlalchemy.engine')
            sql_logger.addHandler(stream_handler)
            sql_logger.setLevel(logging.INFO) 
开发者ID:RagtagOpen,项目名称:nomad,代码行数:18,代码来源:config.py

示例2: create_app

# 需要导入模块: from werkzeug.contrib import fixers [as 别名]
# 或者: from werkzeug.contrib.fixers import ProxyFix [as 别名]
def create_app():
    app = Flask(__name__)
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    from docassemble.base.config import daconfig
    import docassemble.webapp.database
    import docassemble.webapp.db_object
    connect_string = docassemble.webapp.database.connection_string()
    alchemy_connect_string = docassemble.webapp.database.alchemy_connection_string()
    app.config['SQLALCHEMY_DATABASE_URI'] = alchemy_connect_string
    app.secret_key = daconfig.get('secretkey', '38ihfiFehfoU34mcq_4clirglw3g4o87')
    app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
    db = docassemble.webapp.db_object.init_flask()
    db.init_app(app)
    csrf = CSRFProtect()
    csrf.init_app(app)
    babel = Babel()
    babel.init_app(app)
    if daconfig.get('behind https load balancer', False):
        if proxyfix_version >= 15:
            app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1, x_host=1)
        else:
            app.wsgi_app = ProxyFix(app.wsgi_app)
    if 'cross site domains' in daconfig:
        CORS(app, origins=daconfig['cross site domains'], supports_credentials=True)
    return app, csrf, babel 
开发者ID:jhpyle,项目名称:docassemble,代码行数:27,代码来源:app_object.py

示例3: test_ipv4

# 需要导入模块: from werkzeug.contrib import fixers [as 别名]
# 或者: from werkzeug.contrib.fixers import ProxyFix [as 别名]
def test_ipv4(app):
    app.wsgi_app = ProxyFix(app.wsgi_app)
    app.config['VALIDATE_IP'] = True
    app.config['VALIDATE_SIGNATURE'] = False
    client = app.test_client()

    rv = client.post('/', headers={'X-Forwarded-For': '192.30.252.1'})
    assert rv.status_code == 404

    rv = client.post('/hooks', headers={'X-Forwarded-For': '192.30.252.1'})
    assert rv.status_code == 400

    rv = client.post('/hooks', headers={'X-Forwarded-For': '192.30.251.255'})
    assert b'Requests must originate from GitHub' in rv.data
    assert rv.status_code == 403

    rv = client.post('/hooks', headers={'X-Forwarded-For': '192.31.0.1'})
    assert b'Requests must originate from GitHub' in rv.data
    assert rv.status_code == 403 
开发者ID:nickfrostatx,项目名称:flask-hookserver,代码行数:21,代码来源:test_checks.py

示例4: test_ipv6

# 需要导入模块: from werkzeug.contrib import fixers [as 别名]
# 或者: from werkzeug.contrib.fixers import ProxyFix [as 别名]
def test_ipv6(app):
    app.wsgi_app = ProxyFix(app.wsgi_app)
    app.config['VALIDATE_IP'] = True
    app.config['VALIDATE_SIGNATURE'] = False
    client = app.test_client()

    rv = client.post('/', headers={'X-Forwarded-For': '::ffff:c01e:fc01'})
    assert rv.status_code == 404

    rv = client.post('/hooks', headers={'X-Forwarded-For': '::ffff:c01e:fc01'})
    assert rv.status_code == 400

    rv = client.post('/hooks', headers={'X-Forwarded-For': '::ffff:c01e:fbff'})
    assert b'Requests must originate from GitHub' in rv.data
    assert rv.status_code == 403

    rv = client.post('/hooks', headers={'X-Forwarded-For': '::ffff:c01f:1'})
    assert b'Requests must originate from GitHub' in rv.data
    assert rv.status_code == 403 
开发者ID:nickfrostatx,项目名称:flask-hookserver,代码行数:21,代码来源:test_checks.py

示例5: test_all_checks

# 需要导入模块: from werkzeug.contrib import fixers [as 别名]
# 或者: from werkzeug.contrib.fixers import ProxyFix [as 别名]
def test_all_checks(app):
    app.wsgi_app = ProxyFix(app.wsgi_app)
    app.config['GITHUB_WEBHOOKS_KEY'] = b'Some key'
    app.config['VALIDATE_IP'] = True
    app.config['VALIDATE_SIGNATURE'] = True
    client = app.test_client()

    sig = 'e1590250fd7dd7882185062d1ade5bef8cb4319c'
    headers = {
        'X-Forwarded-For': '::ffff:c01e:fc01',
        'X-Hub-Signature': 'sha1=' + sig,
        'X-GitHub-Event': 'ping',
        'X-GitHub-Delivery': 'abc',
    }
    rv = client.post('/hooks', content_type='application/json', data='{}',
                     headers=headers)
    assert rv.status_code == 200 
开发者ID:nickfrostatx,项目名称:flask-hookserver,代码行数:19,代码来源:test_checks.py

示例6: test_secret_key

# 需要导入模块: from werkzeug.contrib import fixers [as 别名]
# 或者: from werkzeug.contrib.fixers import ProxyFix [as 别名]
def test_secret_key(app):
    app.wsgi_app = ProxyFix(app.wsgi_app)
    app.config['SECRET_KEY'] = b'Some key'
    app.config['VALIDATE_IP'] = False
    app.config['VALIDATE_SIGNATURE'] = True
    client = app.test_client()

    sig = 'e1590250fd7dd7882185062d1ade5bef8cb4319c'
    headers = {
        'X-Hub-Signature': 'sha1=' + sig,
        'X-GitHub-Event': 'ping',
        'X-GitHub-Delivery': 'abc',
    }
    rv = client.post('/hooks', content_type='application/json', data='{}',
                     headers=headers)
    assert rv.status_code == 200 
开发者ID:nickfrostatx,项目名称:flask-hookserver,代码行数:18,代码来源:test_checks.py

示例7: mount_apps

# 需要导入模块: from werkzeug.contrib import fixers [as 别名]
# 或者: from werkzeug.contrib.fixers import ProxyFix [as 别名]
def mount_apps(app: Flask):
    app.wsgi_app = ProxyFix(app.wsgi_app)
    wsgiapp = WSGILogger(
        app.wsgi_app, [logging.StreamHandler()], ApacheFormatter(),
        propagate=False)
    cherrypy.tree.graft(wsgiapp, "/")

    cherrypy.tree.mount(None, "/favicon", {
        "/": {
            "tools.staticdir.on": True,
            "tools.staticdir.dir": favicon_dir,
            "tools.etags.on": True,
            "tools.etags.autotags": True
        }
    })

    cherrypy.tree.mount(None, "/public/images", {
        "/": {
            "tools.staticdir.on": True,
            "tools.staticdir.dir": img_dir,
            "tools.etags.on": True,
            "tools.etags.autotags": True
        }
    }) 
开发者ID:chaostoolkit-incubator,项目名称:community-playground,代码行数:26,代码来源:app.py

示例8: init_app

# 需要导入模块: from werkzeug.contrib import fixers [as 别名]
# 或者: from werkzeug.contrib.fixers import ProxyFix [as 别名]
def init_app(cls, app):
        ProductionConfig.init_app(app)

        # handle proxy server headers
        from werkzeug.contrib.fixers import ProxyFix
        app.wsgi_app = ProxyFix(app.wsgi_app)

        # log to stderr
        import logging
        from logging import StreamHandler
        file_handler = StreamHandler()
        file_handler.setLevel(logging.WARNING)
        app.logger.addHandler(file_handler) 
开发者ID:CircleCI-Public,项目名称:circleci-demo-python-flask,代码行数:15,代码来源:config.py

示例9: create_app

# 需要导入模块: from werkzeug.contrib import fixers [as 别名]
# 或者: from werkzeug.contrib.fixers import ProxyFix [as 别名]
def create_app():
    _app = Flask(
            import_name=__name__,
            template_folder='admin/templates/',
            static_folder='admin/static/')

    # used for encrypting cookies for handling sessions
    _app.config['SECRET_KEY'] = 'abc492ee-9739-11e6-a174-07f6b92d4a4b'
    _app.config['ROOT_URL'] = environ.env.config.get(ConfigKeys.ROOT_URL, domain=ConfigKeys.WEB, default='/')

    message_queue_type = environ.env.config.get(ConfigKeys.TYPE, domain=ConfigKeys.QUEUE, default=None)
    if message_queue_type is None and not (len(environ.env.config) == 0 or environ.env.config.get(ConfigKeys.TESTING)):
        raise RuntimeError('no message queue type specified')

    message_queue = 'redis://%s' % environ.env.config.get(ConfigKeys.HOST, domain=ConfigKeys.CACHE_SERVICE, default='')
    message_channel = 'dino_%s' % environ.env.config.get(ConfigKeys.ENVIRONMENT, default='test')

    logger.info('message_queue: %s' % message_queue)

    _socketio = SocketIO(
            _app,
            logger=logger,
            engineio_logger=os.environ.get('DINO_DEBUG', '0') == '1',
            async_mode='eventlet',
            message_queue=message_queue,
            channel=message_channel)

    # preferably "emit" should be set during env creation, but the socketio object is not created until after env is
    environ.env.out_of_scope_emit = _socketio.emit

    _app.wsgi_app = ReverseProxied(ProxyFix(_app.wsgi_app))

    return _app, _socketio 
开发者ID:thenetcircle,项目名称:dino,代码行数:35,代码来源:web.py

示例10: init_app

# 需要导入模块: from werkzeug.contrib import fixers [as 别名]
# 或者: from werkzeug.contrib.fixers import ProxyFix [as 别名]
def init_app(cls, app):
        ProductionConfig.init_app(app)

        # 处理代理服务器首部
        from werkzeug.contrib.fixers import ProxyFix
        app.wsgi_app = ProxyFix(app.wsgi_app)
        # 输出到stderr
        import logging
        from logging import StreamHandler
        file_handler = StreamHandler()
        file_handler.setLevel(logging.WARNING)
        app.logger.addHandler(file_handler) 
开发者ID:Blackyukun,项目名称:Simpleblog,代码行数:14,代码来源:config.py

示例11: init_app

# 需要导入模块: from werkzeug.contrib import fixers [as 别名]
# 或者: from werkzeug.contrib.fixers import ProxyFix [as 别名]
def init_app(cls, app):
        ProductionConfig.init_app(app)
        # 打印日志
        import logging
        from logging import StreamHandler
        file_handler = StreamHandler()
        file_handler.setLevel(logging.WARNING)
        app.logger.addHandler(file_handler)
        # 处理代理服务器头部
        from werkzeug.contrib.fixers import ProxyFix
        app.wsgi_app = ProxyFix(app.wsgi_app) 
开发者ID:jpush,项目名称:jbox,代码行数:13,代码来源:config.py

示例12: create_app

# 需要导入模块: from werkzeug.contrib import fixers [as 别名]
# 或者: from werkzeug.contrib.fixers import ProxyFix [as 别名]
def create_app():
    app = Flask(__name__)
    app.config.from_object(config)
    config.init_app(app)
    app.wsgi_app = ProxyFix(app.wsgi_app)
    cache.init_app(app)
    limiter.init_app(app)

    from .front import front as front_blueprint
    app.register_blueprint(front_blueprint)

    from .admin import admin as admin_blueprint
    app.register_blueprint(admin_blueprint,url_prefix='/{}'.format(GetConfig('admin_prefix')))

    return app 
开发者ID:abbeyokgo,项目名称:PyOne,代码行数:17,代码来源:__init__.py

示例13: init_app

# 需要导入模块: from werkzeug.contrib import fixers [as 别名]
# 或者: from werkzeug.contrib.fixers import ProxyFix [as 别名]
def init_app(cls, app):
        Config.init_app(app)

        # 处理代理服务器首部
        from werkzeug.contrib.fixers import ProxyFix
        app.wsgi_app = ProxyFix(app.wsgi_app) 
开发者ID:Blackyukun,项目名称:dingdian,代码行数:8,代码来源:config.py

示例14: create_app

# 需要导入模块: from werkzeug.contrib import fixers [as 别名]
# 或者: from werkzeug.contrib.fixers import ProxyFix [as 别名]
def create_app(config='udata.settings.Defaults', override=None,
               init_logging=init_logging):
    '''Factory for a minimal application'''
    app = UDataApp(APP_NAME)
    app.config.from_object(config)

    settings = os.environ.get('UDATA_SETTINGS', join(os.getcwd(), 'udata.cfg'))
    if exists(settings):
        app.settings_file = settings  # Keep track of loaded settings for diagnostic
        app.config.from_pyfile(settings)

    if override:
        app.config.from_object(override)

    # Loads defaults from plugins
    for pkg in entrypoints.get_roots(app):
        if pkg == 'udata':
            continue  # Defaults are already loaded
        module = '{}.settings'.format(pkg)
        try:
            settings = importlib.import_module(module)
        except ImportError:
            continue
        for key, default in settings.__dict__.items():
            if key.startswith('__'):
                continue
            app.config.setdefault(key, default)

    app.json_encoder = UDataJsonEncoder

    app.debug = app.config['DEBUG'] and not app.config['TESTING']

    app.wsgi_app = ProxyFix(app.wsgi_app)

    init_logging(app)
    register_extensions(app)

    return app 
开发者ID:opendatateam,项目名称:udata,代码行数:40,代码来源:app.py

示例15: init_app

# 需要导入模块: from werkzeug.contrib import fixers [as 别名]
# 或者: from werkzeug.contrib.fixers import ProxyFix [as 别名]
def init_app(cls, app):
        Config.init_app(app)
        app.wsgi_app = ProxyFix(app.wsgi_app)
        assert os.environ.get('SECRET_KEY'), 'SECRET_KEY IS NOT SET!'

        flask_raygun.Provider(app, app.config['RAYGUN_APIKEY']).attach() 
开发者ID:gita,项目名称:BhagavadGita,代码行数:8,代码来源:config.py


注:本文中的werkzeug.contrib.fixers.ProxyFix方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。