Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在Eve中使用事件挂钩时出现内部服务器错误_Python_Flask_Eve - Fatal编程技术网

Python 在Eve中使用事件挂钩时出现内部服务器错误

Python 在Eve中使用事件挂钩时出现内部服务器错误,python,flask,eve,Python,Flask,Eve,当我发出POST请求时,我正在尝试获取事件。代码如下: from eve import Eve def before_insert(response): print 'About to return artists' app = Eve(settings='settings.py') app.on_insert += before_insert if __name__ == '__main__': app.run() 我在设置文件中没有用于容纳事件的代码-只有在我删除行时可以正常

当我发出POST请求时,我正在尝试获取事件。代码如下:

from eve import Eve

def before_insert(response):
print 'About to return artists'

app = Eve(settings='settings.py')
app.on_insert += before_insert

if __name__ == '__main__':
    app.run()
我在设置文件中没有用于容纳事件的代码-只有在我删除行时可以正常工作的标准代码: app.on\U insert+=插入前

当我发布帖子时,我得到:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>500 Internal Server Error</title>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error and was unable to complete your request.  Either the server is overloaded or there is an error in the application.</p>

500内部服务器错误
内部服务器错误
服务器遇到内部错误,无法完成您的请求。服务器过载或应用程序中存在错误

当我进入资源时,我得到了数据,但帖子还没有被添加


Wassup???

看起来您的回调函数有一个错误的签名。尝试以下方法

from eve import Eve

def before_insert(resource_name, items):
    print 'About to return artists'

app = Eve(settings='settings.py')
app.on_insert += before_insert

if __name__ == '__main__':
    app.run(debug=True)

在任何情况下,请尝试使用设置文件中的
DEBUG=True
运行应用程序,或者使用
app.run(DEBUG=True)
运行应用程序,这样您就可以了解实际问题所在。

您可以发布您的settings.py文件吗?嗨,nicola,这已经解决了问题-谢谢!不知道我怎么会错的。。。很好的框架-也谢谢你