WSGIApplication を変更してメンテナンス モードを作成しました。
私のmain.py
今は次のようになります:
import webapp2
import views
maintenance_mode = False
# These routes need to be always available
routes = [
# Static pages
(r'/(|about|contact|help|faq|terms|privacy|users|methods)',
views.Static),
# Other routes that should always be available here
]
if maintenance_mode:
routes += [(r'/.*', views.Maintenance)] # Displays a maintenance message
application = webapp2.WSGIApplication(routes)
else:
routes += [
# Routes that are not available in maintenance mode
]
application = webapp2.WSGIApplication(routes)
views.py
次のものがあります。
class Maintenance(webapp2.RequestHandler):
def get(self):
self.response.write (
"My app is down for maintenance and should be back up shortly.")
def post(self):
self.response.write (
"My app is down for maintenance and should be back up shortly.")
これは簡単で安全な解決策のように思えますが、このアプローチに欠陥がある場合はお知らせください。