8 class MyHandler(BaseHTTPServer
.BaseHTTPRequestHandler
):
10 leaf
= os
.path
.basename(self
.path
)
11 if next_step
!= ('*',) and leaf
not in next_step
:
12 self
.send_error(404, "Expected %s; got %s" % (next_step
, leaf
))
14 if os
.path
.exists(leaf
):
15 self
.send_response(200)
17 self
.wfile
.write(file(leaf
).read())
20 self
.send_error(404, "Missing: %s" % leaf
)
22 def handle_requests(*script
):
23 server_address
= ('localhost', 8000)
24 httpd
= BaseHTTPServer
.HTTPServer(server_address
, MyHandler
)
30 sys
.stderr
= sys
.stdout
31 print "Waiting for request"
33 for next_step
in script
:
34 if type(next_step
) != tuple: next_step
= (next_step
,)
36 httpd
.handle_request()