blob: 02370a0ea07578f11c30a90a5d16859592f5205f [file] [log] [blame]
# Copyright 2015 the Melange authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Handler for App Engine's warmup requests."""
import httplib
from django import http
from django.conf import urls
from soc.views import base
class WarmupPage(base.RequestHandler):
"""A do-nothing handler for App Engine's warmup requests.
Visit https://cloud.google.com/appengine/docs/python/config/appconfig
and look for warmup request for more details.
Note that the URL path below (/_ah/warmup) is defined in the documentation
above and cannot be modified.
"""
def __init__(self):
"""Initializes a new instance of the request handler."""
super(WarmupPage, self).__init__(None, None, None, None)
def djangoURLPatterns(self):
"""See base.RequestHandler.djangoURLPatterns for specification."""
return [urls.url(r'^_ah/warmup$', self)]
def __call__(self, request):
"""Handler for incoming HTTP.
Only GET method is allowed and the handler does not do anything but
immediately returns 204 No Content response.
Returns:
An http.HttpResponse object whose status is set to No Content for each
handled GET request. Method Not Allowed is returned for each other method.
"""
return (
http.HttpResponse(status=httplib.NO_CONTENT)
if request.method == 'GET'
else http.HttpResponse(status=httplib.METHOD_NOT_ALLOWED))
WARMUP_PAGE = WarmupPage()