Google App引擎内部服务器错误

时间:2015-04-23 16:42:50

标签: python web-applications

此代码以500内部服务器错误响应,但我找不到问题。

class Customer(ndb.Model):
 # Because we will use email address as an ID/key, no need to define it.
 name = ndb.StringProperty(required=True)
 registered = ndb.DateProperty(auto_now_add=True)
 def toJSON(self):
     jsondata = {
     "email" : self.key.id(),
     "name" : self.name,
     "registered" : str(self.registered)
     }
     return json.encode(jsondata)       

class NewCustomerHandler(webapp2.RequestHandler):

  def get(self):
     # Assuming values to create a customer are passed in query variables..
     email = self.request.get('email')
     name = self.request.get('name')
     callback = self.request.get('callback')
     cust = Customer(id=email)
     cust.name = name
     cust.put() # The customer is now in the database
     self.response.write(callback + '({"response":“Customer added”})')
         self.response.write(callback+'({"response":"Not found."})')

app = webapp2.WSGIApplication([
 ('/cust', NewCustomerHandler),
], debug=True)

1 个答案:

答案 0 :(得分:0)

查看应用程序日志应该可以更轻松地解决问题。

在这个特定的例子中,您的应用可能会崩溃,因为您在这里有不正确的缩进:

 self.response.write(callback + '({"response":“Customer added”})')
     self.response.write(callback+'({"response":"Not found."})')