#!/usr/bin/python

import os
import cgi
import cgitb
cgitb.enable()

def aant_url():
    form = cgi.FieldStorage()
    aa_residue = form.getfirst("aa_residue")
    aa_moiety = form.getfirst("aa_moiety")
    nt_residue = form.getfirst("nt_residue")
    nt_moiety = form.getfirst("nt_moiety")
    return "/%s-%s/%s/%s/" % (nt_moiety, aa_moiety, nt_residue, aa_residue)

def main():
    url = aant_url()
    print "HTTP/1.0 302 Found"
    print "Server: %s" % os.environ['SERVER_SOFTWARE']
    print "Location: %s" % url
    print "Content-type: text/html"
    print ""
    print "<html>"
    print "<head>"
    print "<title>302 Found</title>"
    print "</head>"
    print "<body>"
    print "<h1>Found</h1>"
    print '<p>The document is <a href="%s">here</a>.</p>' % url
    print "</body>"
    print "</html>"
    return 0

main()
