de-cgi-bin/shorturl.py
changeset 22 72696ca68c34
parent 19 8d3ffd87cb0b
equal deleted inserted replaced
21:b75f9514e797 22:72696ca68c34
     1 #!/usr/bin/env python2.4
     1 #!/usr/bin/env python2.5
     2 #
     2 #
     3 # DeGAL - A pretty simple web image gallery
     3 # DeGAL - A pretty simple web image gallery
     4 # Copyright (C) 2007 Tero Marttila
     4 # Copyright (C) 2007 Tero Marttila
     5 # http://marttila.de/~terom/degal/
     5 # http://marttila.de/~terom/degal/
     6 #
     6 #
    18 # along with this program; if not, write to the
    18 # along with this program; if not, write to the
    19 # Free Software Foundation, Inc.,
    19 # Free Software Foundation, Inc.,
    20 # 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
    20 # 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
    21 #
    21 #
    22 
    22 
    23 import cgi
    23 import inc
       
    24 from lib import shorturl, req
    24 
    25 
    25 import inc
    26 key = req.get_str('key')
    26 from lib import shorturl
    27 index = req.get_int('index', None)
    27 
    28 
    28 vars = cgi.FieldStorage()
    29 path = shorturl.html_path(key)
    29 
    30 
    30 key = vars['key'].value
    31 if path :
       
    32     print "Status: 302"
       
    33     print "Location: ../%s" % path
       
    34     print
       
    35     print "../%s" % path
    31 
    36 
    32 if 'index' in vars :
       
    33     index = int(vars['index'].value.lstrip('/'))
       
    34 else :
    37 else :
    35     index = None
    38     print "Status: 404"
       
    39     print
       
    40     print "404"
    36 
    41 
    37 db = shorturl.DB()
       
    38 
       
    39 path = db.html_path(key, index)
       
    40 
       
    41 print "Status: 302"
       
    42 print "Location: ../%s" % path
       
    43 print
       
    44 print "../%s" % path
       
    45