似乎解决方案非常简单(它一直躲藏在我的眼前,因为它被隐藏了):
__name__是 main 而不是 main !
简而言之,以下代码
main()按预期使用了:
# with main()import webapp2class GetHandler(webapp2.RequestHandler): def get(self): self.response.headers['Content-Type'] = 'text/plain' self.response.write('in GET')class SetHandler(webapp2.RequestHandler): def get(self): self.response.headers['Content-Type'] = 'text/plain' self.response.write('in SET')def main(): global app app = webapp2.WSGIApplication([ ('/get', GetHandler), ('/set', SetHandler), ], debug=True)# Note that it's 'main' and not '__main__'if __name__ == 'main': main()
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)