Exemple #1
0
    def recv(self, environ, start_response):
        formdata = environ["QUERY_STRING"]
        results = urlparse.parse_qs(formdata)

        print results

        amount = results["amount"][0]

        print amount
        num_amount = db.convert_to_ml(amount)

        content_type = "text/html"

        if num_amount != -1:
            data1 = "Amount in ML: %d; <a href='./'>return to index</a>" % (num_amount)
        else:
            data1 = "Unknown Units; <a href='./'>return to index</a>"

        data = """\

<head><title>Form Results</title>
<style type="text/css">
h1 {color:red;}
</style>
</head>
<body>
<h1>Form Results</h1>"""

        data += data1
        data += """
Visit:
<a href='content'>a file</a>,
<a href='error'>an error</a>,
<a href='helmet'>an image</a>,
<a href='somethingelse'>something else</a>, or
<a href='form'>a form...</a>
<a href='inventory'>Inventory</a>
<a href='recipes'>Recipes</a>
<a href='index'>Index</a>
<p>
<img src='/helmet'>
</body>
"""

        start_response("200 OK", list(html_headers))
        return [data]
Exemple #2
0
    def li_recv(self, environ, start_response):
        formdata = environ["QUERY_STRING"]
        results = urlparse.parse_qs(formdata)

        mfg = results["mfg"][0]
        liquor = results["liquor"][0]
        amount = results["amount"][0]

        num_amount = db.convert_to_ml(amount)

        content_type = "text/html"

        if num_amount != -1:
            amount = "Amount in ML: %d" % (num_amount)
        else:
            amount = "Unknown Units"

        db.add_to_inventory(mfg, liquor, amount)

        data = """\

<head><title>Form Results</title>
<style type="text/css">
h1 {color:red;}
</style>
</head>
<body>
<h1>Form Results</h1>"""

        data += "Mfg: " + mfg
        data += "Liquor: " + liquor
        data += amount
        data += """
Visit:

<a href='index'>Index</a>

"""

        start_response("200 OK", list(html_headers))
        return [data]
Exemple #3
0
 def rpc_convert(self, a):
     print "in rpc convert"
     return db.convert_to_ml(a)
Exemple #4
0
    def rpc_convert_units_to_ml(self,amount):        
	return str(db.convert_to_ml(amount))