Created
February 16, 2011 03:35
-
-
Save onishi/828817 to your computer and use it in GitHub Desktop.
statuscode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from google.appengine.ext import webapp | |
from google.appengine.ext.webapp.util import run_wsgi_app | |
import httplib | |
class StatusCode(webapp.RequestHandler): | |
def get(self, code): | |
self.response.headers['Content-Type'] = 'text/html' | |
content = 'statuscode : ' + code + '<br>' | |
for c, m in httplib.responses.iteritems(): | |
content += "<li><a href=\"/statuscode/%(code)d\">%(code)d %(message)s</a></li>\n" % {'code':c, 'message':m} | |
self.response.out.write(content) | |
if code: | |
self.response.set_status(int(code), message=None) | |
application = webapp.WSGIApplication([ | |
(r'/statuscode/?(\d*)', StatusCode), | |
], debug=True) | |
def main(): | |
run_wsgi_app(application) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment