猿问

Python Eve - REST API additional_lookup 不起作用

我面临着与此处描述的完全相同的问题。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,我会得到想要的回应。


慕尼黑8549860
浏览 157回答 1
1回答
随时随地看视频慕课网APP

相关分类

Python
我要回答