Created
July 2, 2010 04:53
-
-
Save hiratara/460946 to your computer and use it in GitHub Desktop.
This file contains 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 | |
def _adjust_path_info(script_path, environ): | |
if environ["PATH_INFO"].startswith(script_path): | |
environ["SCRIPT_NAME"] += script_path | |
environ["PATH_INFO"] = environ["PATH_INFO"][len(script_path):] | |
def as_handler(wsgi): | |
class WSGIHandler(webapp.RequestHandler): | |
def get(self, *array): | |
_adjust_path_info(self.get_url(*array), self.request.environ) | |
status_string, header_list, app_iter = \ | |
self.request.call_application(wsgi) | |
code = int(status_string.split(" ", 2)[0]) | |
self.response.set_status(code) | |
for k, v in header_list: | |
self.response.headers.add_header(k, v) | |
for l in app_iter: self.response.out.write(l) | |
post = get | |
head = get | |
options = get | |
put = get | |
delete = get | |
trace = get | |
return WSGIHandler | |
def as_wsgi(handler): | |
return webapp.WSGIApplication([('.*', handler)]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment