def do_GET(self):
     try:
         if self.path.endswith("/restaurants"):
             self.send_response(200)
             self.send_header('Content-type', 'text/html')
             self.end_headers()
             listOfRestaurants = getListOfRestaurants()
             output = ""
             output += "<html><body><table>"
             output += "<a href='/restaurants/new'>Make a New Restaurant</a>"
             count = 0
             for restaurant in listOfRestaurants:
                 output += "<tr><td>%s</br>" % restaurant.name
                 output += ('''<a href="{}/edit">Edit</a></br>''').format(restaurant.id)
                 output += '''<a href="{}/delete">Delete</a></br>'''.format(restaurant.id)
                 output += "<br>"
             output += "</table></body></html>"
             self.wfile.write(output)
             print (output)
             return
         if self.path.endswith("/restaurants/new"):
             self.send_response(200)
             self.send_header('Content-type', 'text/html')
             self.end_headers()
             output = ""
             output += "<html><body>"
             output += "<h1>Make a New Restaurant</h1>"
             output += "<form method='POST' enctype='multipart/form-data' action='/createRestaurant'><input name='newName' type='text' placeholder='New Restaurant Name'><input type='submit' value='Submit'></form>"
             output += "</html></body>"
             self.wfile.write(output)
             print (output)
         if self.path.endswith("/edit"):
             self.send_response(200)
             self.send_header('Content-type', 'text/html')
             self.end_headers()
             path = self.path
             restaurantId = (re.findall('\d{1}', path))[0]
             oldRestaurantName = getRestaurantById(restaurantId)
             output = ""
             output += "<html><body>"
             output += "<h1>Edit Restaurant</h1>"
             output += ("<h1>{}</h1>").format(oldRestaurantName)
             output += ("<form method='POST' enctype='multipart/form-data' action='/{}/editRestaurant'><input name='newRestaurantName' type='text' placeholder='New Restaurant Name'><input type='submit' value='Submit'></form>").format(restaurantId)
             output += "</html></body>"
             self.wfile.write(output)
         if self.path.endswith("/delete"):
             self.send_response(200)
             self.send_header('Content-type', 'text/html')
             self.end_headers()
             restaurantId = (re.findall('\d{1}', self.path))[0]
             oldRestaurantName = getRestaurantById(restaurantId)
             output = ""
             output += "<html><body>"
             output += "<h1>Delete Restaurant</h1>"
             output += ("<h1>{}</h1>").format(oldRestaurantName)
             output += ("<form method='POST' enctype='multipart/form-data' action='/{}/deleteRestaurant'><input type='submit' value='Submit'></form>").format(restaurantId)
             output += "</html></body>"
             self.wfile.write(output)
     except IOError:
         self.send_error(404, 'File Not Found: %s' % self.path)
def restaurantList():
    restaurants = getListOfRestaurants()
    return render_template('menulist.html', restaurants = restaurants)