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


Python request.scheme方法代码示例

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


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

示例1: exceptions

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import scheme [as 别名]
def exceptions(e):
    tb = traceback.format_exc()
    tb = tb.decode('utf-8')
    logger.error('%s %s %s %s 5xx INTERNAL SERVER ERROR\n%s',
                 request.environ.get('HTTP_X_REAL_IP', request.remote_addr),
                 request.method, request.scheme, request.full_path, tb)
    return '500 INTERNAL SERVER ERROR', 500 
开发者ID:521xueweihan,项目名称:hellogithub.com,代码行数:9,代码来源:__init__.py

示例2: _prepare_flask_request

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import scheme [as 别名]
def _prepare_flask_request():
        # If server is behind proxys or balancers use the HTTP_X_FORWARDED fields
        url_data = urlparse(request.url)
        port = url_data.port or (443 if request.scheme == 'https' else 80)

        return {
            'https': 'on' if request.scheme == 'https' else 'off',
            'http_host': request.host,
            'server_port': port,
            'script_name': request.path,
            'get_data': request.args.copy(),
            'post_data': request.form.copy()
        } 
开发者ID:RiotGames,项目名称:cloud-inquisitor,代码行数:15,代码来源:__init__.py

示例3: after_request

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import scheme [as 别名]
def after_request(response):
	timestamp = strftime('[%Y-%b-%d %H:%M]')
	logger.error('%s %s %s %s %s %s',timestamp , request.remote_addr , \
				request.method , request.scheme , request.full_path , response.status)
	return response 
开发者ID:highoncarbs,项目名称:shorty,代码行数:7,代码来源:app.py

示例4: exceptions

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import scheme [as 别名]
def exceptions(e):
	tb = traceback.format_exc()
	timestamp = strftime('[%Y-%b-%d %H:%M]')
	logger.error('%s %s %s %s %s 5xx INTERNAL SERVER ERROR\n%s',
        timestamp, request.remote_addr, request.method,
        request.scheme, request.full_path, tb)
	return make_response(e , 405) 
开发者ID:highoncarbs,项目名称:shorty,代码行数:9,代码来源:app.py

示例5: after_request

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import scheme [as 别名]
def after_request(response):
    logger.info('%s %s %s %s %s', request.method,
                request.environ.get('HTTP_X_REAL_IP', request.remote_addr),
                request.scheme, request.full_path, response.status)
    return response 
开发者ID:521xueweihan,项目名称:hellogithub.com,代码行数:7,代码来源:__init__.py

示例6: from_manifest

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import scheme [as 别名]
def from_manifest(app, filename, raw=False, **kwargs):
    '''
    Get the path to a static file for a given app entry of a given type.

    :param str app: The application key to which is tied this manifest
    :param str filename: the original filename (without hash)
    :param bool raw: if True, doesn't add prefix to the manifest
    :return: the resolved file path from manifest
    :rtype: str
    '''
    cfg = current_app.config

    if current_app.config.get('TESTING'):
        return  # Do not spend time here when testing

    path = _manifests[app][filename]

    if not raw and cfg.get('CDN_DOMAIN') and not cfg.get('CDN_DEBUG'):
        scheme = 'https' if cfg.get('CDN_HTTPS') else request.scheme
        prefix = '{}://'.format(scheme)
        if not path.startswith('/'):  # CDN_DOMAIN has no trailing slash
            path = '/' + path
        return ''.join((prefix, cfg['CDN_DOMAIN'], path))
    elif not raw and kwargs.get('external', False):
        if path.startswith('/'):  # request.host_url has a trailing slash
            path = path[1:]
        return ''.join((request.host_url, path))
    return path 
开发者ID:opendatateam,项目名称:udata,代码行数:30,代码来源:assets.py

示例7: post_move

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import scheme [as 别名]
def post_move():
    new_move = request.get_json()
    move = Move.query.get(new_move['id'])

    if move:
        return jsonify(result='success')

    if not move:
        move = Move.deserialize(new_move)

    if not move.valid:
        return jsonify(result='failed',
                       message=f"move {move.id} isn't valid."), 400

    db.session.add(move)
    try:
        db.session.commit()
    except IntegrityError:
        return jsonify(result='failed',
                       message="This node already has this move."), 400
    sent_node = Node()
    if 'sent_node' in new_move:
        sent_node.url = new_move['sent_node']

    move_broadcast.delay(
        move.id,
        sent_node_url=sent_node.url,
        my_node_url=f'{request.scheme}://{request.host}'
    )
    return jsonify(result='success') 
开发者ID:nekoyume,项目名称:nekoyume,代码行数:32,代码来源:api.py

示例8: after_request

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import scheme [as 别名]
def after_request(response):
    """After request handler."""
    service_log.info(
        '{0} {1} {2} {3} {4}'.format(
            request.remote_addr, request.method, request.scheme,
            request.full_path, response.status
        )
    )

    return response 
开发者ID:SwissDataScienceCenter,项目名称:renku-python,代码行数:12,代码来源:entrypoint.py

示例9: exceptions

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import scheme [as 别名]
def exceptions(e):
    """App exception logger."""
    tb = traceback.format_exc()
    service_log.error(
        '{} {} {} {} 5xx INTERNAL SERVER ERROR\n{}'.format(
            request.remote_addr, request.method, request.scheme,
            request.full_path, tb
        )
    )

    return e.status_code 
开发者ID:SwissDataScienceCenter,项目名称:renku-python,代码行数:13,代码来源:entrypoint.py

示例10: _is_enabled

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import scheme [as 别名]
def _is_enabled():
        return request.scheme == 'https' 
开发者ID:cloudify-cosmo,项目名称:cloudify-manager,代码行数:4,代码来源:manager.py

示例11: init_saml_auth

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import scheme [as 别名]
def init_saml_auth():
    parsed_url = urlparse(request.url)
    request_data = {
        "https": "on" if request.scheme == "https" else "off",
        "http_host": request.host,
        "server_port": parsed_url.port,
        "script_name": request.path,
        "get_data": request.args.copy(),
        "post_data": request.form.copy(),
        "query_string": request.query_string
        }

    auth = OneLogin_Saml2_Auth(request_data, custom_base_path=get_env("INFRABOX_ACCOUNT_SAML_SETTINGS_PATH"))
    return auth 
开发者ID:SAP,项目名称:InfraBox,代码行数:16,代码来源:saml.py

示例12: _add_gopher_error_handler

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import scheme [as 别名]
def _add_gopher_error_handler(self, app):
        """
        Intercept all errors for GOPHER requests and replace the default
        HTML error document with a gopher compatible text document.
        """
        def handle_error(error):
            if request.scheme != 'gopher':
                # Pass through the error to the default handler
                return error

            code = getattr(error, 'code', 500)
            name = getattr(error, 'name', 'Internal Server Error')
            desc = getattr(error, 'description', None)
            if desc is None and self.show_stack_trace:
                desc = traceback.format_exc()
            elif desc is None:
                desc = 'An internal error has occurred'
            body = [menu.error(code, name), '', self.formatter.wrap(desc)]

            # There's no way to know if the client has requested a gopher
            # menu, a text file, or a binary file. But we can make a guess
            # based on if the request path has a file extension at the end.
            ext = os.path.splitext(request.path)[1]
            if ext:
                return '\r\n'.join(body)
            else:
                return self.render_menu(*body)

        # Attach this handler to all of the builtin flask exceptions
        for cls in HTTPException.__subclasses__():
            app.register_error_handler(cls, handle_error) 
开发者ID:michael-lazar,项目名称:flask-gopher,代码行数:33,代码来源:flask_gopher.py

示例13: after_request

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import scheme [as 别名]
def after_request(response):
    if response.status_code != 500:
        ts = strftime('[%Y-%b-%d %H:%M]')
        logger.info('%s %s %s %s %s %s',
                      ts,
                      request.remote_addr,
                      request.method,
                      request.scheme,
                      request.full_path,
                      response.status)
    return(response) 
开发者ID:kylechenoO,项目名称:AIOPS_PLATFORM,代码行数:13,代码来源:WebApp.py

示例14: exceptions

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import scheme [as 别名]
def exceptions(e):
    """ Logging after every Exception. """
    ts = strftime('[%Y-%b-%d %H:%M]')
    logger.error('%s %s %s %s %s 5xx INTERNAL SERVER ERROR',
                  ts,
                  request.remote_addr,
                  request.method,
                  request.scheme,
                  request.full_path)
    return("Internal Server Error", 500) 
开发者ID:kylechenoO,项目名称:AIOPS_PLATFORM,代码行数:12,代码来源:WebApp.py

示例15: error_handler

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import scheme [as 别名]
def error_handler(ex):
    logger.exception(
        'An error has occurred! ({} {} {} {})'.format(
            request.remote_addr, request.method, request.scheme, request.full_path
        )
    )
    return 'Internal Server Error', 500 
开发者ID:snowflakedb,项目名称:SnowAlert,代码行数:9,代码来源:app.py


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