当使用Python Eve数据库钩子时,我试图在后调用上修改请求参数我收到以下错误
<!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>
当我删除代码片段以修改请求参数时,资源就会成功创建。
请将代码段找到: -
__author__ = 'sappal'
from eve import Eve
import time
def insert_people(items):
# retrieve request parameter, if present
print items['userid']
print items['email']
items['userid']= "Tushar_Sappal" + str(int(time.time()))
items['email'] = "sappal.tushar"+str(int(time.time()))+"@gmail.com"
print items
# Creating the instance of the EVE Application
app = Eve()
app.on_insert_people += insert_people
if __name__== '__main__':
app.run(host='0.0.0.0')
答案 0 :(得分:1)
items
是一个列表,因此您应该像这样更新代码:
def insert_people(items):
for item in items:
item['userid']= "Tushar_Sappal" + str(int(time.time()))
item['email'] = "sappal.tushar"+str(int(time.time()))+"@gmail.com"
在开发过程中,您通常希望以调试模式运行应用程序,因此您可以获得包含错误的完整堆栈跟踪:
app.run(debug=True)
确保在生产中运行时禁用调试模式。