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