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)