python - 无法搜索 eve rest API - 附加查找不起作用

标签 python rest eve

我正在遵循这里的示例:https://github.com/pyeve/eve-demo/blob/master/settings.py

当我转到 localhost:5000/apps 时,我可以看到我的集合中的所有文档,但是当我在 localhost:5000/apps/[email protected] 搜索电子邮件时,它显示“404 未找到”。

我已经确认了正则表达式,并且电子邮件地址位于文档中。谁能看出可能出了什么问题吗?

运行.py

from eve import Eve


if __name__ == '__main__':
    app = Eve()
    app.run()

设置.py:

RESOURCE_METHODS = ['GET', 'POST', 'DELETE']
ITEM_METHODS = ['GET', 'PATCH', 'PUT', 'DELETE']


MONGO_HOST = 'localhost'
MONGO_PORT = 27017
MONGO_DBNAME = 'test_database'



apps = {
    'item_title' : 'app',

    'additional_lookup' : {
    'url' : 'regex("\b[\w.-]+?@\w+?\.\w+?\b")',
    'field' : 'developer_email',
    },

        'schema': {
            'address' : {
                'type' : 'string'
                },
            'developer_email' : {
                'type' : 'string',
                'minlength' : 1,
                'maxlength' : 15,
                'required' : True,
                'unique' : True,
            }
            }

DOMAIN = {
    'apps' : apps,
}

最佳答案

在您的 settings.py 中,您没有正确进行查找。应该是这样。

apps = {
    'item_title' : 'app',

    'additional_lookup' : {
    'url' : 'apps/regex("\b[\w.-]+?@\w+?\.\w+?\b")',
    'field' : 'developer_email',
    },

        'schema': {
            'address' : {
                'type' : 'string'
                },
            'developer_email' : {
                'type' : 'string',
                'minlength' : 1,
                'maxlength' : 15,
                'required' : True,
                'unique' : True,
            }
            }

关于python - 无法搜索 eve rest API - 附加查找不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43838785/

相关文章:

python - 如何定义架构以使列表不允许为空?

python - 导入 Eve,但运行 run.py 时,显示没有名为 eve 的模块

python - 使用python,我应该将大数据缓存在数组中并一次写入文件吗?

python - Pandas :如何指定起始行以提取数据

python - AttributeError at/accounts/signup/'str' 对象没有属性 'add'

java - 在 Java 中,如何从 Resteasy 验证返回有意义的 JSON 格式错误?

java - Jackson 无法反序列化日期

java - 使用 Spring REST 服务获取 NPE

python - Eve with Postman "must be of list type"错误

python - Python 文件名中的冒号