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


Python reqparse.RequestParser方法代码示例

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


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

示例1: post

# 需要导入模块: from flask_restful import reqparse [as 别名]
# 或者: from flask_restful.reqparse import RequestParser [as 别名]
def post(self):
        parser = reqparse.RequestParser()
        parser.add_argument('fullname', type=str, help='You need to enter your full name', required=True)
        parser.add_argument('email', type=str, help='You need to enter your e-mail address', required=True)
        parser.add_argument('password', type=str, help='You need to enter your chosen password', required=True)
        parser.add_argument('password_conf', type=str, help='You need to enter the confirm password field', required=True)
        
        args = parser.parse_args()
        
        email = args.get('email')
        password = args.get('password')
        password_conf = args.get('password_conf')
        fullname = args.get('fullname')
        
        try:
            User.create(
                email=email,
                password=password,
                password_conf=password_conf,
                fullname=fullname
            )
            return {'message': 'Successfully created your account.'}
        except ValidationError as e:
            abort(400, message='There was an error while trying to create your account -> {}'.format(e.message)) 
开发者ID:afropolymath,项目名称:papers,代码行数:26,代码来源:auth.py

示例2: get_arguments

# 需要导入模块: from flask_restful import reqparse [as 别名]
# 或者: from flask_restful.reqparse import RequestParser [as 别名]
def get_arguments(self):
        parser = reqparse.RequestParser()
        parser.add_argument("person_id", default=None)
        parser.add_argument("comment", default="")
        parser.add_argument("name", default="main")
        parser.add_argument("revision", default=1, type=int)
        parser.add_argument("change_status", default=True, type=bool)
        args = parser.parse_args()

        return (
            args["person_id"],
            args["comment"],
            args["name"],
            args["revision"],
            args["change_status"],
        ) 
开发者ID:cgwire,项目名称:zou,代码行数:18,代码来源:resources.py

示例3: delete

# 需要导入模块: from flask_restful import reqparse [as 别名]
# 或者: from flask_restful.reqparse import RequestParser [as 别名]
def delete(self, instance_id):
        parser = reqparse.RequestParser()
        parser.add_argument("force", default=False, type=bool)
        args = parser.parse_args()

        project = self.get_model_or_404(instance_id)
        project_dict = project.serialize()
        if projects_service.is_open(project_dict):
            return {
                "error": True,
                "message": "Only closed projects can be deleted"
            }, 400
        else:
            self.check_delete_permissions(project_dict)
            if args["force"] == True:
                deletion_service.remove_project(instance_id)
            else:
                project.delete()
            self.post_delete(project_dict)
            return "", 204 
开发者ID:cgwire,项目名称:zou,代码行数:22,代码来源:project.py

示例4: get_arguments

# 需要导入模块: from flask_restful import reqparse [as 别名]
# 或者: from flask_restful.reqparse import RequestParser [as 别名]
def get_arguments(self):
        parser = reqparse.RequestParser()
        parser.add_argument(
            "email", help="The email is required.", required=True
        )
        parser.add_argument(
            "first_name", help="The first name is required.", required=True
        )
        parser.add_argument(
            "last_name", help="The last name is required.", required=True
        )
        parser.add_argument("phone", default="")
        parser.add_argument("role", default="user")
        parser.add_argument("desktop_login", default="")
        args = parser.parse_args()
        return args 
开发者ID:cgwire,项目名称:zou,代码行数:18,代码来源:resources.py

示例5: get_arguments

# 需要导入模块: from flask_restful import reqparse [as 别名]
# 或者: from flask_restful.reqparse import RequestParser [as 别名]
def get_arguments(self):
        parser = reqparse.RequestParser()
        parser.add_argument("only_preview", default=False, type=bool)
        parser.add_argument("task_type_id", default=None)
        parser.add_argument("task_status_id", default=None)
        parser.add_argument("page", default=1, type=int)
        parser.add_argument("page_size", default=50, type=int)
        args = parser.parse_args()

        return (
            args["only_preview"],
            args["task_type_id"],
            args["task_status_id"],
            args["page"],
            args["page_size"],
        ) 
开发者ID:cgwire,项目名称:zou,代码行数:18,代码来源:resources.py

示例6: get_arguments

# 需要导入模块: from flask_restful import reqparse [as 别名]
# 或者: from flask_restful.reqparse import RequestParser [as 别名]
def get_arguments(self):
        parser = reqparse.RequestParser()
        parser.add_argument(
            "task_status_id", required=True, help="Task Status ID is missing"
        )
        parser.add_argument("comment", default="")
        parser.add_argument("person_id", default="")
        if request.json is None:
            parser.add_argument("checklist", default="[]")
            args = parser.parse_args()
            checklist = args["checklist"]
            checklist = json.loads(checklist)
        else:
            parser.add_argument("checklist", type=dict, action="append", default=[])
            args = parser.parse_args()
            checklist = args["checklist"]

        return (
            args["task_status_id"],
            args["comment"],
            args["person_id"],
            checklist
        ) 
开发者ID:cgwire,项目名称:zou,代码行数:25,代码来源:resources.py

示例7: get_arguments

# 需要导入模块: from flask_restful import reqparse [as 别名]
# 或者: from flask_restful.reqparse import RequestParser [as 别名]
def get_arguments(self):
        maxsoft = files_service.get_or_create_software("3ds Max", "max", ".max")

        parser = reqparse.RequestParser()
        parser.add_argument("name", default="main")
        parser.add_argument("mode", default="working")
        parser.add_argument("software_id", default=maxsoft["id"])
        parser.add_argument("comment", default="")
        parser.add_argument("revision", default=0)
        parser.add_argument("sep", default="/")
        args = parser.parse_args()

        return (
            args["name"],
            args["mode"],
            args["software_id"],
            args["comment"],
            args["revision"],
            args["sep"],
        ) 
开发者ID:cgwire,项目名称:zou,代码行数:22,代码来源:resources.py

示例8: get

# 需要导入模块: from flask_restful import reqparse [as 别名]
# 或者: from flask_restful.reqparse import RequestParser [as 别名]
def get(self, id=None):
        parser = reqparse.RequestParser()
        parser.add_argument('delete', type=int)
        parser.add_argument('offset', type=int)
        parser.add_argument('limit', type=int)
        args = parser.parse_args()
        if id is None:
            if args['offset'] is not None and args['limit'] is not None:
                return self.list(args['offset'], args['limit'])
            else:
                return self.list()
        else:
            if args['delete'] == 1:
                return self.delete(id)
            else:
                return self.read(id) 
开发者ID:talos-vulndev,项目名称:FuzzFlow,代码行数:18,代码来源:Engine.py

示例9: post

# 需要导入模块: from flask_restful import reqparse [as 别名]
# 或者: from flask_restful.reqparse import RequestParser [as 别名]
def post(self, id=None):
        parser = reqparse.RequestParser()
        if id is None:
            parser.add_argument('name', required=True, location='json')
            parser.add_argument('path', required=True, location='json')
            parser.add_argument('platform_id', required=True, location='json')
            parser.add_argument('arch_id', required=True, location='json')
            parser.add_argument('options', location='json')
            return self.create(parser.parse_args())
        else:
            parser.add_argument('name', location='json')
            parser.add_argument('path', location='json')
            parser.add_argument('platform_id', location='json')
            parser.add_argument('arch_id', location='json')
            parser.add_argument('options', location='json')
            return self.update(id, parser.parse_args()) 
开发者ID:talos-vulndev,项目名称:FuzzFlow,代码行数:18,代码来源:Engine.py

示例10: get

# 需要导入模块: from flask_restful import reqparse [as 别名]
# 或者: from flask_restful.reqparse import RequestParser [as 别名]
def get(self, id=None):
        parser = reqparse.RequestParser()
        parser.add_argument('delete', type=int)
        parser.add_argument('type', type=int)
        parser.add_argument('offset', type=int)
        parser.add_argument('limit', type=int)
        args = parser.parse_args()
        if id is None:
            if args['offset'] is not None and args['limit'] is not None:
                return self.list(args['offset'], args['limit'])
            elif args['type'] == 1:
                return self.type()
            else:
                return self.list()
        else:
            if args['delete'] == 1:
                return self.delete(id)
            else:
                return self.read(id) 
开发者ID:talos-vulndev,项目名称:FuzzFlow,代码行数:21,代码来源:Option.py

示例11: get

# 需要导入模块: from flask_restful import reqparse [as 别名]
# 或者: from flask_restful.reqparse import RequestParser [as 别名]
def get(self, id=None):
        parser = reqparse.RequestParser()
        parser.add_argument('delete', type=int)
        parser.add_argument('offset', type=int)
        parser.add_argument('limit', type=int)
        parser.add_argument('state', type=int)
        parser.add_argument('host', type=int)
        args = parser.parse_args()
        if id is None:
            if args['offset'] is not None and args['limit'] is not None:
                return self.list(args['offset'], args['limit'])
            elif args['state'] == 1:
                return self.state()
            else:
                return self.list()
        else:
            if args['delete'] == 1:
                return self.delete(id)
            elif args['host'] == 1:
                return self.read(id, 'host')
            else:
                return self.read(id) 
开发者ID:talos-vulndev,项目名称:FuzzFlow,代码行数:24,代码来源:Job.py

示例12: post

# 需要导入模块: from flask_restful import reqparse [as 别名]
# 或者: from flask_restful.reqparse import RequestParser [as 别名]
def post(self, id=None):
        parser = reqparse.RequestParser()
        if id is None:
            parser.add_argument('name', required=True, location='json')
            parser.add_argument('state_id', required=True, location='json')
            parser.add_argument('engine_id', required=True, location='json')
            parser.add_argument('target_id', required=True, location='json')
            parser.add_argument('options', type=list, location='json')
            parser.add_argument('host_id', location='json')
            parser.add_argument('output', location='json')
            return self.create(parser.parse_args())
        else:
            parser.add_argument('name', location='json')
            parser.add_argument('state_id', location='json')
            parser.add_argument('engine_id', location='json')
            parser.add_argument('target_id', location='json')
            parser.add_argument('options', type=list, location='json')
            parser.add_argument('host_id', location='json')
            parser.add_argument('output', location='json')
            return self.update(id, parser.parse_args()) 
开发者ID:talos-vulndev,项目名称:FuzzFlow,代码行数:22,代码来源:Job.py

示例13: post

# 需要导入模块: from flask_restful import reqparse [as 别名]
# 或者: from flask_restful.reqparse import RequestParser [as 别名]
def post(self, id=None):
        parser = reqparse.RequestParser()
        if id is None:
            parser.add_argument('name', required=True, location='json')
            parser.add_argument('path', required=True, location='json')
            parser.add_argument('platform_id', required=True, location='json')
            parser.add_argument('arch_id', required=True, location='json')
            parser.add_argument('visible', type=int, location='json')
            return self.create(parser.parse_args())
        else:
            parser.add_argument('name', location='json')
            parser.add_argument('path', location='json')
            parser.add_argument('visible', type=int, location='json')
            parser.add_argument('platform_id', location='json')
            parser.add_argument('arch_id', location='json')
            return self.update(id, parser.parse_args()) 
开发者ID:talos-vulndev,项目名称:FuzzFlow,代码行数:18,代码来源:Target.py

示例14: get

# 需要导入模块: from flask_restful import reqparse [as 别名]
# 或者: from flask_restful.reqparse import RequestParser [as 别名]
def get(self, id=None):
        parser = reqparse.RequestParser()
        parser.add_argument('delete', type=int)
        parser.add_argument('offset', type=int)
        parser.add_argument('limit', type=int)
        parser.add_argument('host', type=int)

        args = parser.parse_args()
        if id is None:
            if args['offset'] is not None and args['limit'] is not None:
                return self.list(args['offset'], args['limit'])
            else:
                return self.list()
        else:
            if args['delete'] == 1:
                return self.delete(id)
            elif args['host'] == 1:
                return self.read(id, 'host')
            else:
                return self.read(id) 
开发者ID:talos-vulndev,项目名称:FuzzFlow,代码行数:22,代码来源:_deprecated_Config.py

示例15: post

# 需要导入模块: from flask_restful import reqparse [as 别名]
# 或者: from flask_restful.reqparse import RequestParser [as 别名]
def post(self, id=None):
        parser = reqparse.RequestParser()
        if id is None:
            parser.add_argument('host_id', required=True, location='json')
            parser.add_argument('arch_id', required=True, location='json')
            parser.add_argument('platform_id', required=True, location='json')
            parser.add_argument('engines', location='json')
            parser.add_argument('targets', location='json')
            return self.create(parser.parse_args())
        else:
            parser.add_argument('host_id', location='json')
            parser.add_argument('arch_id', location='json')
            parser.add_argument('platform_id', location='json')
            parser.add_argument('engines', location='json')
            parser.add_argument('targets', location='json')
            return self.update(id, parser.parse_args()) 
开发者ID:talos-vulndev,项目名称:FuzzFlow,代码行数:18,代码来源:_deprecated_Config.py


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