From 4d39f3305cea947cfd811b6fbc838beca7abbd79 Mon Sep 17 00:00:00 2001 From: Adriaan Beiertz <22228397+adriaanbd@users.noreply.github.com> Date: Tue, 14 Aug 2018 18:45:17 -0500 Subject: [PATCH] Update webserver.py Changed so it can work in Python 2.7 --- Lesson-2/Objective-4-Solution/webserver.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Lesson-2/Objective-4-Solution/webserver.py b/Lesson-2/Objective-4-Solution/webserver.py index 505af75..50ab18f 100644 --- a/Lesson-2/Objective-4-Solution/webserver.py +++ b/Lesson-2/Objective-4-Solution/webserver.py @@ -32,9 +32,9 @@ def do_GET(self): self.wfile.write(output) return if self.path.endswith("/edit"): - restaurantIDPath = self.path.split("/")[2] + restaurantIDPath = self.path.split("/")[1] myRestaurantQuery = session.query(Restaurant).filter_by( - id=restaurantIDPath).one() + id=restaurantIDPath).first() if myRestaurantQuery: self.send_response(200) self.send_header('Content-type', 'text/html') @@ -86,10 +86,10 @@ def do_POST(self): if ctype == 'multipart/form-data': fields = cgi.parse_multipart(self.rfile, pdict) messagecontent = fields.get('newRestaurantName') - restaurantIDPath = self.path.split("/")[2] + restaurantIDPath = self.path.split("/")[1] myRestaurantQuery = session.query(Restaurant).filter_by( - id=restaurantIDPath).one() + id=restaurantIDPath).first() if myRestaurantQuery != []: myRestaurantQuery.name = messagecontent[0] session.add(myRestaurantQuery)