comparison static_file_serving.py @ 15:7a59f0eceee7 default tip

static_file_serving serves on port 8000 if it's run as a script now.
author Atul Varma <avarma@mozilla.com>
date Fri, 18 Jun 2010 15:07:35 -0700
parents 63ea847bfa75
children
comparison
equal deleted inserted replaced
14:b8c699d8e613 15:7a59f0eceee7
1 #! /usr/bin/env python
2
1 import mimetypes 3 import mimetypes
2 import os 4 import os
3 import wsgiref.util 5 import wsgiref.util
4 6
5 class StaticFileApp(object): 7 class StaticFileApp(object):
27 return wsgiref.util.FileWrapper(f) 29 return wsgiref.util.FileWrapper(f)
28 else: 30 else:
29 return error_404() 31 return error_404()
30 32
31 return error_404() 33 return error_404()
34
35 if __name__ == '__main__':
36 from wsgiref.simple_server import make_server
37
38 dirname = os.getcwd()
39 port = 8000
40 httpd = make_server('', port, StaticFileApp(dirname))
41 print "Serving files on port %d at %s." % (port, dirname)
42 httpd.serve_forever()