當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。