def add_a_new_recipe_recv(self, environ, start_response): print "in add_a_new_recipe_recv" formdata = environ['QUERY_STRING'] results = urlparse.parse_qs(formdata) name = results['name'][0] ings = results['ings'][0] indv_ings = ings.split(',') ind_list =[] for item in indv_ings: myTup = tuple(item.split(':')) ind_list.append(myTup) recipe = recipes.Recipe(name,ind_list) db.add_recipe(recipe) db.save_db('bin/sample_database') taste_of_success = db.get_recipe(name) if taste_of_success == recipe: data = generate_html.generate_recipes_html() else: content_type = 'text/html' data = """ <html> <head> <title>Failure to add recipe!</title> <style type ="text/css"> h1{color:red;} </style> </head> <body>""" data += """Failed to add Recipe, please try again!""" data += generate_html.generate_menu() data += """ </body> </html> """ start_response('200 OK', list(html_headers)) return [data]
def recipes(self, environ, start_response): data = generate_html.generate_recipes_html() start_response('200 OK', list(html_headers)) return [data]