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