我能够通过以下链接在谷歌应用引擎中运行Hello World程序 https://cloud.google.com/appengine/docs/python/
但是在我修改了main.py文件的代码(试用新的处理程序)后,我收到了以下错误。
Traceback (most recent call last):
File "/home/natesan/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1535, in __call__
rv = self.handle_exception(request, response, e)
File "/home/natesan/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1529, in __call__
rv = self.router.dispatch(request, response)
File "/home/natesan/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)
File "/home/natesan/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 1102, in __call__
return handler.dispatch()
File "/home/natesan/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)
File "/home/natesan/google_appengine/lib/webapp2-2.5.2/webapp2.py", line 570, in dispatch
return method(*args, **kwargs)
File "/home/natesan/webapps/udacity1/main.py", line 29, in get
self.request.get(q)
NameError: global name 'q' is not defined
main.py文件如下。
import webapp2
form="""
<form action="/Testform">
<input name="q" >
<input type="submit">
</form>
"""
class TestHandler(webapp2.RequestHandler):
def get(self):
self.request.get(q)
self.response.write(q)
class MainHandler(webapp2.RequestHandler):
def get(self):
self.response.write(form)
app = webapp2.WSGIApplication([
('/', MainHandler),('/Testform',TestHandler)
], debug=True)
任何人都可以帮我解决错误。