]> git.ipfire.org Git - ipfire.org.git/blob - www/index.py
Merge branch 'master' of git://git.ipfire.org/ipfire.org
[ipfire.org.git] / www / index.py
1 #!/usr/bin/python
2
3 import os
4 import re
5 import cgi
6
7 sites = (
8 ("ipfire.org", ("www.ipfire.org", None)),
9 ("www.ipfire.org", (None, cgi.FieldStorage().getfirst("file") or "index.shtml")),
10 ("source.ipfire.org", (None, "source.shtml")),
11 ("tracker.ipfire.org", (None, "tracker.shtml")),
12 ("download.ipfire.org", (None, "download.shtml")),
13 )
14
15 # Check language...
16 language = "en"
17 try:
18 if re.search(re.compile("^de(.*)"), os.environ["HTTP_ACCEPT_LANGUAGE"]):
19 language = "de"
20 except KeyError:
21 pass
22
23 print "Status: 302 Moved"
24 print "Pragma: no-cache"
25
26 location = ""
27
28 for (servername, destination) in sites:
29 if servername == os.environ["SERVER_NAME"]:
30 if destination[0]:
31 location = "http://%s" % destination[0]
32 if destination[1]:
33 location += "/%s/%s" % (language, destination[1])
34 break
35
36 print "Location: %s" % location
37 print # End the header