本文整理汇总了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))
示例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"],
)
示例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
示例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
示例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"],
)
示例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
)
示例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"],
)
示例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)
示例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())
示例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)
示例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)
示例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())
示例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())
示例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)
示例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())