author | terom |
Thu, 08 Nov 2007 19:09:05 +0000 | |
changeset 5 | 156cdfffef8e |
parent 3 | 9637b8f24005 |
child 6 | d9d1f8e5f384 |
permissions | -rwxr-xr-x |
1 | 1 |
#!/usr/bin/env python2.5 |
2 |
||
2 | 3 |
import shelve |
1 | 4 |
import cgi |
5 |
import os, os.path |
|
6 |
||
7 |
vars = cgi.FieldStorage() |
|
8 |
||
9 |
key = vars['key'].value |
|
2 | 10 |
db = shelve.open('shorturls2', 'r') |
1 | 11 |
|
12 |
try : |
|
2 | 13 |
type, dirpath, fname = db[key] |
14 |
||
5
156cdfffef8e
fix shorturls to dirs, and a new feature: pagination for index pages
terom
parents:
3
diff
changeset
|
15 |
if type == 'dir' : fname = 'index' |
156cdfffef8e
fix shorturls to dirs, and a new feature: pagination for index pages
terom
parents:
3
diff
changeset
|
16 |
|
3
9637b8f24005
...and fix it to redirect to the .html. Series.cgi is also refactored+commented+shorturls2'd
terom
parents:
2
diff
changeset
|
17 |
path = os.path.join(dirpath, fname) + '.html' |
1 | 18 |
finally : |
19 |
db.close() |
|
20 |
||
21 |
print "Status: 302" |
|
22 |
print "Location: ../%s" % path |
|
23 |
||
24 |
print "../%s" % path |
|
25 |