Skip to content

Instantly share code, notes, and snippets.

@soundkitchen
Created October 11, 2011 10:06
Show Gist options
  • Save soundkitchen/1277749 to your computer and use it in GitHub Desktop.
Save soundkitchen/1277749 to your computer and use it in GitHub Desktop.
CGIHTTPServer を / でも動くように野良化してみた。
#!/usr/bin/env python
# vim: fileencoding=utf-8 :
from CGIHTTPServer import test, CGIHTTPRequestHandler as BaseRequestHandler
class CGIHTTPRequestHandler(BaseRequestHandler):
def is_cgi(self):
path = self.path
if path.endswith('.py'):
try:
i = path.rindex('/')
self.cgi_info = path[:i], path[i+1:]
except ValueError, e:
self.cgi_info = '', path
return True
return False
def main():
test(CGIHTTPRequestHandler)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment