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


Python reqparse.RequestParser方法代码示例

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


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

示例1: post

# 需要导入模块: from flask.ext.restful import reqparse [as 别名]
# 或者: from flask.ext.restful.reqparse import RequestParser [as 别名]
def post(self):
        req_parser = reqparse.RequestParser()
        req_parser.add_argument('code', type=str, required=True)
        req_parser.add_argument('password', type=str, required=True)
        args = req_parser.parse_args()

        password_reset = db.session.query(PasswordReset
                            ).filter(PasswordReset.code==args['code']
                            ).filter(PasswordReset.date>datetime.now()).first()

        if not password_reset:
            return CODE_NOT_VALID

        password_reset.user.set_password(args['password'])
        db.session.delete(password_reset)
        db.session.commit()

        return {}, 200 
开发者ID:projectweekend,项目名称:Flask-PostgreSQL-API-Seed,代码行数:20,代码来源:api.py

示例2: post

# 需要导入模块: from flask.ext.restful import reqparse [as 别名]
# 或者: from flask.ext.restful.reqparse import RequestParser [as 别名]
def post(self):
        """
        Handle setting the architechture settings.
        """
        parser = reqparse.RequestParser()
        parser.add_argument('filter_bytes', type=str, required=True,
                            location='json')
        
        args = parser.parse_args()
        ASSEMBLY_STORE.filter_bytes = binascii.unhexlify(args.filter_bytes)
        
        ASSEMBLY_STORE.ClearErrors()
        
        for row in ASSEMBLY_STORE.GetRowsIterator():
            ASSEMBLER.CheckOpcodeBytes(row, ASSEMBLY_STORE)
            
        return jsonify(success="1") 
开发者ID:pmarkowsky,项目名称:dash,代码行数:19,代码来源:rest_api.py

示例3: get

# 需要导入模块: from flask.ext.restful import reqparse [as 别名]
# 或者: from flask.ext.restful.reqparse import RequestParser [as 别名]
def get(self):
        parser = reqparse.RequestParser()
        parser.add_argument('topic')
        parser.add_argument('id')

        args = parser.parse_args()
        topic = args['topic']
        index = 'default'
        if "id" in args:
            index = args['id']

        times, poems, rhyme_words, table_html = get_rhyme_interactive(
            topic, index)
        d = {}
        d['rhyme_words'] = rhyme_words

        json_str = json.dumps(d, ensure_ascii=False)
        r = make_response(json_str)
        sm.clear_status(index)

        return r 
开发者ID:shixing,项目名称:poem,代码行数:23,代码来源:client_es.py

示例4: get

# 需要导入模块: from flask.ext.restful import reqparse [as 别名]
# 或者: from flask.ext.restful.reqparse import RequestParser [as 别名]
def get(self):
        parser = reqparse.RequestParser()
        parser.add_argument('positive', type=str, required=False, help="Positive words.", action='append')
        parser.add_argument('negative', type=str, required=False, help="Negative words.", action='append')
        parser.add_argument('topn', type=int, required=False, help="Number of results.")
        args = parser.parse_args()
        pos = filter_words(args.get('positive', []))
        neg = filter_words(args.get('negative', []))
        t = args.get('topn', 10)
        pos = [] if pos == None else pos
        neg = [] if neg == None else neg
        t = 10 if t == None else t
        print "positive: " + str(pos) + " negative: " + str(neg) + " topn: " + str(t)
        try:
            res = model.most_similar_cosmul(positive=pos,negative=neg,topn=t)
            return res
        except Exception, e:
            print e
            print res 
开发者ID:nishankmahore,项目名称:word2vec-flask-api,代码行数:21,代码来源:word2vec-api.py

示例5: ns_all

# 需要导入模块: from flask.ext.restful import reqparse [as 别名]
# 或者: from flask.ext.restful.reqparse import RequestParser [as 别名]
def ns_all():
    """ Return all namespaces """
    # We do this outside the blueprint to support the case of an empty
    # public_id.  However, this means the before_request isn't run, so we need
    # to make our own session
    with global_session_scope() as db_session:
        parser = reqparse.RequestParser(argument_class=ValidatableArgument)
        parser.add_argument('limit', default=DEFAULT_LIMIT, type=limit,
                            location='args')
        parser.add_argument('offset', default=0, type=int, location='args')
        parser.add_argument('email_address', type=bounded_str, location='args')
        args = strict_parse_args(parser, request.args)

        query = db_session.query(Namespace)
        if args['email_address']:
            query = query.join(Account)
            query = query.filter_by(email_address=args['email_address'])

        query = query.limit(args['limit'])
        if args['offset']:
            query = query.offset(args['offset'])

        namespaces = query.all()
        encoder = APIEncoder()
        return encoder.jsonify(namespaces) 
开发者ID:nylas,项目名称:sync-engine,代码行数:27,代码来源:srv.py

示例6: __init__

# 需要导入模块: from flask.ext.restful import reqparse [as 别名]
# 或者: from flask.ext.restful.reqparse import RequestParser [as 别名]
def __init__(self):
        super(BasicResource, self).__init__()
        self.parser = reqparse.RequestParser() 
开发者ID:projectweekend,项目名称:Pi-GPIO-Server,代码行数:5,代码来源:meta.py

示例7: post_put_parser

# 需要导入模块: from flask.ext.restful import reqparse [as 别名]
# 或者: from flask.ext.restful.reqparse import RequestParser [as 别名]
def post_put_parser():
    """Request parser for HTTP POST or PUT.
    :returns: flask.ext.restful.reqparse.RequestParser object

    """
    parse = reqparse.RequestParser()
    parse.add_argument(
        'username', type=str, location='json', required=True)
    parse.add_argument(
        'password', type=str, location='json', required=True)

    return parse 
开发者ID:alexandre-old,项目名称:flask-rest-template,代码行数:14,代码来源:resources.py

示例8: _post_put_parser

# 需要导入模块: from flask.ext.restful import reqparse [as 别名]
# 或者: from flask.ext.restful.reqparse import RequestParser [as 别名]
def _post_put_parser(self):
        """Request parser for HTTP POST or PUT.
        :returns: flask.ext.restful.reqparse.RequestParser object

        """
        parse = reqparse.RequestParser()
        parse.add_argument(
            'username', type=str, location='json', required=True)
        parse.add_argument(
            'password', type=str, location='json', required=True)

        return parse 
开发者ID:alexandre-old,项目名称:flask-rest-template,代码行数:14,代码来源:resources.py

示例9: __init__

# 需要导入模块: from flask.ext.restful import reqparse [as 别名]
# 或者: from flask.ext.restful.reqparse import RequestParser [as 别名]
def __init__(self, *args, **kwargs):
        RestResource.__init__(self, *args, **kwargs)

        self._parser = reqparse.RequestParser()
        self._parser.add_argument("name", type=str)
        self._parser.add_argument("url", type=str) 
开发者ID:davidoren,项目名称:CuckooSploit,代码行数:8,代码来源:dist.py

示例10: start

# 需要导入模块: from flask.ext.restful import reqparse [as 别名]
# 或者: from flask.ext.restful.reqparse import RequestParser [as 别名]
def start():
    g.api_version = request.headers.get('Api-Version', API_VERSIONS[0])

    if g.api_version not in API_VERSIONS:
        g.api_version = API_VERSIONS[0]

    if g.api_version == API_VERSIONS[0]:
        g.api_features = APIFeatures(optimistic_updates=True)
    else:
        g.api_features = APIFeatures(optimistic_updates=False)

    request.environ['log_context'] = {
        'endpoint': request.endpoint,
        'api_version': g.api_version,
        'namespace_id': g.namespace_id,
    }

    engine = engine_manager.get_for_id(g.namespace_id)
    g.db_session = new_session(engine)
    g.namespace = Namespace.get(g.namespace_id, g.db_session)

    if not g.namespace:
        # The only way this can occur is if there used to be an account that
        # was deleted, but the API access cache entry has not been expired yet.
        raise AccountDoesNotExistError()

    request.environ['log_context']['account_id'] = g.namespace.account_id
    if hasattr(g, 'application_id'):
        request.environ['log_context']['application_id'] = g.application_id

    is_n1 = request.environ.get('IS_N1', False)
    g.encoder = APIEncoder(g.namespace.public_id, is_n1=is_n1)

    g.parser = reqparse.RequestParser(argument_class=ValidatableArgument)
    g.parser.add_argument('limit', default=DEFAULT_LIMIT, type=limit,
                          location='args')
    g.parser.add_argument('offset', default=0, type=offset, location='args') 
开发者ID:nylas,项目名称:sync-engine,代码行数:39,代码来源:ns_api.py

示例11: put

# 需要导入模块: from flask.ext.restful import reqparse [as 别名]
# 或者: from flask.ext.restful.reqparse import RequestParser [as 别名]
def put(self, row_index):
        """
        Edit the values of a row via an HTTP PUT request.

        Args:
          row_index: an integer index into the assembly store

        Returns:
          A tuple of http return code and a dictionary to be serialized to JSON
        """
        try:
            row = ASSEMBLY_STORE.GetRow(row_index)
        except AssemblyStoreError:
            abort(404)

        parser = reqparse.RequestParser()
        parser.add_argument('offset', type=int, default=row.offset, 
                            location='json')
        parser.add_argument('label', default=row.label, location='json')
        parser.add_argument('address', type=str, default=row.address,
                            location='json')
        parser.add_argument('opcode', default=row.opcode, location='json')
        parser.add_argument('mnemonic', default=row.mnemonic, location='json')
        parser.add_argument('comment', default=row.comment, location='json')
        #this defaults to true as adding any data makes a row in use
        parser.add_argument('in_use', default=True, location='json')
        args = parser.parse_args()
        row.offset = args.offset
        row.SetLabel(args.label)
        row.SetAddress(args.address)
        row.SetComment(args.comment)
        row.in_use = args.in_use

        ASSEMBLY_STORE.UpdateRow(row.index, row)

        if str(args.opcode).strip() != row.opcode:
            row.SetOpcode(args.opcode)
            ASSEMBLY_STORE.UpdateRow(row.index, row)

            if row.error:
                return row.ToDict()

            ASSEMBLER.Disassemble(row.index, ASSEMBLY_STORE)
        else:

            if args.mnemonic != row.mnemonic or args.mnemonic == '':
                if args.mnemonic == '':
                   # delete the row. 
                    ASSEMBLY_STORE.DeleteRow(row_index)
                    return row.ToDict()
                else:
                    new_mnemonics = args.mnemonic.split(';')
                    self.InsertMultipleRowsByMnemonic(row, new_mnemonics)
            else:
                ASSEMBLY_STORE.UpdateRow(row.index, row)
            ASSEMBLER.Assemble(ASSEMBLY_STORE)

        row = ASSEMBLY_STORE.GetRow(row.index)
        return row.ToDict() 
开发者ID:pmarkowsky,项目名称:dash,代码行数:61,代码来源:rest_api.py


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