Fixed argument parsing in errlogger and multifscgi.
[ashd.git] / examples / python / dynhosts / dynhosts
1 #!/usr/bin/python
2
3 import os, sys, signal
4 from ashd import util
5
6 children = {}
7 root = sys.argv[1]
8 signal.signal(signal.SIGCHLD, signal.SIG_IGN)
9
10 def serve(req):
11     if "Host" in req:
12         # Strip port specification
13         dname = req["Host"].split(':')[0]
14         dname = dname.lower()
15         path = os.path.join(root, dname)
16         if os.path.isdir(path):
17             if dname not in children:
18                 children[dname] = util.pchild(["dirplex", path], autorespawn = True)
19             children[dname].passreq(req)
20             return
21     util.respond(req, "No such host in configured.\n", status = "404 Not Found", ctype = "text/plain")
22
23 util.serveloop(serve)