为了账号安全,请及时绑定邮箱和手机立即绑定

Python Eve - REST API additional_lookup 不起作用

Python Eve - REST API additional_lookup 不起作用

慕尼黑8549860 2021-06-08 20:35:58
我面临着与此处描述的完全相同的问题。user_creds我的 API有端点。当我访问 时localhost:5000/user_creds/,我可以看到该集合中的所有文档。但是当我做类似的事情时localhost:5000/user_creds/someemail@gmail.com,我总是收到 404 Not Found 响应。user_creds settings.py 中的域如下所示:'user_creds': {        'schema': {             'email': {                'type': 'string',                'regex': r"(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)",                'required': True,                'unique': True,            },            'password': {                'type': 'string',                'required': True            },        }        'resource_methods': ['GET', 'POST'],        'item_methods': ['GET', 'PATCH', 'PUT'],        'additional_lookup': {            'url': 'regex("^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$")',            'field': 'email'        }    }我正在按照此处给出的示例进行操作,但无法弄清楚我哪里出错了。此外,如果我访问此 URL: http://127.0.0.1:5000/user_creds?email==%22abcd12@gmail.com%22,我将获得集合中的所有文档,而不是仅获得与电子邮件正则表达式匹配的单个文档。如果我访问这个http://127.0.0.1:5000/user_creds?where=email==%22abcd12@gmail.com%22,我会得到想要的回应。
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 156 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号