Commit | Line | Data |
---|---|---|
7f838309 FT |
1 | #!/usr/bin/python |
2 | ||
3 | import os, sys, signal | |
4 | from ashd import util | |
5 | ||
6 | children = {} | |
7 | root = sys.argv[1] | |
0c345c82 FT |
8 | |
9 | # Automatically reap all children that die for any reason. | |
7f838309 FT |
10 | signal.signal(signal.SIGCHLD, signal.SIG_IGN) |
11 | ||
12 | def serve(req): | |
13 | if "Host" in req: | |
14 | # Strip port specification | |
15 | dname = req["Host"].split(':')[0] | |
16 | dname = dname.lower() | |
17 | path = os.path.join(root, dname) | |
18 | if os.path.isdir(path): | |
19 | if dname not in children: | |
20 | children[dname] = util.pchild(["dirplex", path], autorespawn = True) | |
21 | children[dname].passreq(req) | |
22 | return | |
ca92a4e5 | 23 | util.respond(req, "No such host is configured.\n", status = "404 Not Found", ctype = "text/plain") |
7f838309 FT |
24 | |
25 | util.serveloop(serve) |