修改请求参数抛出Internal Server Error
Modifying the Request parameters throws Internal Server Error
使用 Python Eve 数据库挂钩时,我试图修改 post 调用中的请求参数,但出现以下错误
<!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')
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)
在生产环境中 运行 确保禁用调试模式。
使用 Python Eve 数据库挂钩时,我试图修改 post 调用中的请求参数,但出现以下错误
<!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')
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)
在生产环境中 运行 确保禁用调试模式。