Message99953
I'd like to put something like this in Doc, to make it easier to actually review the built documentation. (I guess we could put it in Tools, I'd just like it better if it was right there with the other stuff.)
Good idea? Thomas Wouters kind of liked it but said I should ask you.
from wsgiref.simple_server import make_server
import mimetypes, sys, os
CWD = os.path.dirname(os.path.abspath(__file__))
ROOT = os.path.join(CWD, 'build', 'html')
def app(environ, respond):
fn = os.path.join(ROOT, environ['PATH_INFO'][1:])
if '.' not in fn.split(os.path.sep)[-1]:
fn = os.path.join(fn, 'index.html')
type = mimetypes.guess_type(fn)[0]
if os.path.exists(fn):
respond('200 OK', [('Content-Type', type)])
return [open(fn).read()]
else:
respond('404 Not Found', [('Content-Type', 'text/plain')])
return ['not found']
if __name__ == '__main__':
port = int(sys.argv[1]) if len(sys.argv) > 1 else 8000
httpd = make_server('', port, app)
httpd.serve_forever() |
|
Date |
User |
Action |
Args |
2010-02-23 21:22:06 | djc | set | recipients:
+ djc, benjamin.peterson |
2010-02-23 21:22:06 | djc | set | messageid: <1266960126.19.0.905943018148.issue8004@psf.upfronthosting.co.za> |
2010-02-23 21:22:05 | djc | link | issue8004 messages |
2010-02-23 21:22:04 | djc | create | |
|