如何在GAE(Google App Engine)中使用Python main()函数?

如何在GAE(Google App Engine)中使用Python main()函数?,第1张

如何在GAE(Google App Engine)中使用Python main()函数

似乎解决方案非常简单(它一直躲藏在我的眼前,因为它被隐藏了):

__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()


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5663438.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存