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


Python request.query_string方法代码示例

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


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

示例1: answer

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import query_string [as 别名]
def answer(topic = None):
    """
    Main rendering function, it processes incoming weather queries.
    Depending on user agent it returns output in HTML or ANSI format.

    Incoming data:
        request.args
        request.headers
        request.remote_addr
        request.referrer
        request.query_string
    """

    user_agent = request.headers.get('User-Agent', '').lower()
    html_needed = is_html_needed(user_agent)
    options = parse_query(request.args)
    hostname = request.headers['Host']

    if request.headers.getlist("X-Forwarded-For"):
       ip = request.headers.getlist("X-Forwarded-For")[0]
       if ip.startswith('::ffff:'):
           ip = ip[7:]
    else:
       ip = request.remote_addr

    if topic is None:
        topic = ":firstpage"

    answer = cmd_wrapper(topic, hostname=hostname, request_options=options, html=is_html_needed(user_agent))
    
    if ip not in SKIP_LOGGING_FOR_THIS_IPS:
        log_query(ip, hostname, topic, user_agent)
    return answer 
开发者ID:chubin,项目名称:rate.sx,代码行数:35,代码来源:srv.py

示例2: get_current_url

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import query_string [as 别名]
def get_current_url():
    if not request.query_string:
        return request.path
    return '%s?%s' % (request.path, request.query_string) 
开发者ID:danielecook,项目名称:Quiver-alfred,代码行数:6,代码来源:flask_utils.py

示例3: get

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import query_string [as 别名]
def get(self, args):
        # We need to give each resource a unique ID so the client doesn't try to cache
        # or reconcile different plots
        request_hash = sha1(request.query_string).hexdigest()

        plots = plot.trend_data(plot_prefix=request_hash, **args)

        return schemas.TrendSchema(many=True, unknown=INCLUDE).dump(plots) 
开发者ID:ewels,项目名称:MegaQC,代码行数:10,代码来源:views.py

示例4: go_view

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import query_string [as 别名]
def go_view(object_key):
  url = url_for('{}_view'.format(constants.get('MODE')), object_key=object_key)
  response = redirect('{}?{}'.format(url, request.query_string))
  return cached(response, datetime.datetime.utcnow(), expires=0) 
开发者ID:yasyf,项目名称:shamer,代码行数:6,代码来源:app.py

示例5: prepare_auth_request

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import query_string [as 别名]
def prepare_auth_request(request):
    url_data = urlparse(request.url)
    return {
        "https": 'on',
        'http_host': request.host,
        'server_port': url_data.port,
        'script_name': request.path,
        'get_data': request.args.copy(),
        'post_data': request.form.copy(),
        # Uncomment if using ADFS as IdP, https://github.com/onelogin/python-saml/pull/144
        # 'lowercase_urlencoding': True,
        'query_string': request.query_string
    } 
开发者ID:certsocietegenerale,项目名称:fame,代码行数:15,代码来源:views.py

示例6: log_request

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import query_string [as 别名]
def log_request(f):
    @wraps(f)
    def decorated_function(*args, **kwargs):
        LOG.info('API request url %s', request.url)
        if request.query_string:
            LOG.info('API query string %s', request.query_string)
        LOG.info('API request method %s', request.method)
        if request.method == 'POST':
            LOG.info('API POST data %s', request.json)
        LOG.debug('API request environ %s', request.environ)
        return f(*args, **kwargs)
    return decorated_function 
开发者ID:smartbgp,项目名称:yabgp,代码行数:14,代码来源:utils.py

示例7: init_saml_auth

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

示例8: _get_devices

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import query_string [as 别名]
def _get_devices():
    db = aeon_ztp.db.session
    to_json = device_schema

    # ---------------------------------------------------------------
    # if the request has arguments, use these to form an "and" filter
    # and return only the subset of items matching
    # ---------------------------------------------------------------

    if request.args:
        try:
            recs = find_devices(db, request.args.to_dict())
            if len(recs) == 0:
                return jsonify(ok=False,
                               message='Not Found: %s' % request.query_string), 404

            items = [to_json.dump(rec).data for rec in recs]
            return jsonify(count=len(items), items=items)

        except AttributeError:
            return jsonify(ok=False, message='invalid arguments'), 500

    # -------------------------------------------
    # otherwise, return all items in the database
    # -------------------------------------------

    items = [to_json.dump(rec).data for rec in db.query(Device).all()]
    return jsonify(count=len(items), items=items)


# -----------------------------------------------------------------------------
#                                 POST /api/devices
# ----------------------------------------------------------------------------- 
开发者ID:Apstra,项目名称:aeon-ztps,代码行数:35,代码来源:views.py

示例9: _delete_devices

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import query_string [as 别名]
def _delete_devices():
    if request.args.get('all'):
        try:
            db = aeon_ztp.db.session
            db.query(Device).delete()
            db.commit()

        except Exception as exc:
            return jsonify(
                ok=False,
                message='unable to delete all records: {}'.format(exc.message)), 400

        return jsonify(ok=True, message='all records deleted')

    elif request.args:
        db = aeon_ztp.db.session
        try:
            recs = find_devices(db, request.args.to_dict())
            n_recs = len(recs)
            if n_recs == 0:
                return jsonify(ok=False,
                               message='Not Found: %s' % request.query_string), 404

            for dev in recs:
                db.delete(dev)
            db.commit()
            return jsonify(
                ok=True, count=n_recs,
                message='{} records deleted'.format(n_recs))

        except AttributeError:
            return jsonify(ok=False, message='invalid arguments'), 500

        except Exception as exc:
            msg = 'unable to delete specific records: {}'.format(exc.message)
            return jsonify(ok=False, message=msg), 500
    else:
        return jsonify(ok=False, message='all or filter required'), 400 
开发者ID:Apstra,项目名称:aeon-ztps,代码行数:40,代码来源:views.py

示例10: _get_uri_from_request

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import query_string [as 别名]
def _get_uri_from_request(request):
    """
    The uri returned from request.uri is not properly urlencoded
    (sometimes it's partially urldecoded) This is a weird hack to get
    werkzeug to return the proper urlencoded string uri
    """
    uri = request.base_url
    if request.query_string:
        uri += '?' + request.query_string.decode('utf-8')
    return uri 
开发者ID:gita,项目名称:BhagavadGita,代码行数:12,代码来源:utils.py

示例11: get_hosts

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import query_string [as 别名]
def get_hosts():
    """Return all hosts."""
    #Check for query string, redirect to endpoint with trailling '/'.
    if request.query_string:
        return redirect(url_for('run_cmd') + '?' + request.query_string)
    hosts = RSPET_API.get_hosts()
    return jsonify({'hosts': [make_public_host(hosts[h_id], h_id) for h_id in hosts]}) 
开发者ID:panagiks,项目名称:RSPET,代码行数:9,代码来源:rspet_server_api.py

示例12: get_host

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import query_string [as 别名]
def get_host(host_id):
    """Return specific host."""
    #Check for query string, redirect to endpoint with trailling '/'.
    if request.query_string:
        return redirect(url_for('run_cmd_host', host_id=host_id) + '?' + request.query_string)
    hosts = RSPET_API.get_hosts()
    try:
        host = hosts[host_id]
    except KeyError:
        abort(404)
    return jsonify(make_public_host(host, host_id)) 
开发者ID:panagiks,项目名称:RSPET,代码行数:13,代码来源:rspet_server_api.py

示例13: oauth_callback

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import query_string [as 别名]
def oauth_callback():
    handshaker = Handshaker(
        "https://meta.wikimedia.org/w/index.php",
        oauth_token,
        user_agent=user_agent
    )
    try:
        access_token = handshaker.complete(session['request_token'], request.query_string)
    except (OAuthException, KeyError) as e:
        exception(e)
        flash('Fatal error occured while login (%s). Please try again after cleaning the cookies in your browser.'
              % str(e), 'danger')
        return redirect(url_for('index'))
    session['access_token'] = access_token
    identity = handshaker.identify(access_token)
    wiki_uid = identity['sub']
    user = g.conn.session.query(User).filter(User.wiki_uid == wiki_uid).first()
    if user is None:
        user = User(username=identity['username'], wiki_uid=wiki_uid)
        g.conn.session.add(user)
        g.conn.session.commit()
        flash('Welcome to Quarry, %s!' % user.username, 'success')
    elif user.username != identity['username']:
        user.username = identity['username']
        g.conn.session.add(user)
        try:
            g.conn.session.commit()
        except IntegrityError as e:
            if e[0] == 1062:  # Duplicate
                g.conn.session.rollback()
            else:
                raise

    session['user_id'] = user.id
    return_to_url = session.get('return_to_url')
    del session['request_token']
    del session['return_to_url']
    return redirect(return_to_url) 
开发者ID:wikimedia,项目名称:analytics-quarry-web,代码行数:40,代码来源:login.py


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