Back to index

python3.2  3.2.2
Functions | Variables
serve Namespace Reference

Functions

def app

Variables

list path = sys.argv[1]
tuple port = int(sys.argv[2])
tuple httpd = simple_server.make_server('', port, app)

Function Documentation

def serve.app (   environ,
  respond 
)

Definition at line 13 of file serve.py.

00013 
00014 def app(environ, respond):
00015 
00016     fn = os.path.join(path, environ['PATH_INFO'][1:])
00017     if '.' not in fn.split(os.path.sep)[-1]:
00018         fn = os.path.join(fn, 'index.html')
00019     type = mimetypes.guess_type(fn)[0]
00020 
00021     if os.path.exists(fn):
00022         respond('200 OK', [('Content-Type', type)])
00023         return util.FileWrapper(open(fn, "rb"))
00024     else:
00025         respond('404 Not Found', [('Content-Type', 'text/plain')])
00026         return ['not found']

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

tuple serve.httpd = simple_server.make_server('', port, app)

Definition at line 30 of file serve.py.

list serve.path = sys.argv[1]

Definition at line 28 of file serve.py.

tuple serve.port = int(sys.argv[2])

Definition at line 29 of file serve.py.