save completed ch. 3 work (not tested)

This commit is contained in:
2022-01-12 15:19:02 -06:00
parent c119fa6921
commit 17040c282f
4 changed files with 196 additions and 0 deletions
+20
View File
@@ -1,6 +1,8 @@
from http.server import BaseHTTPRequestHandler, HTTPServer
from views import get_all_animals, get_single_animal
from http.server import BaseHTTPRequestHandler, HTTPServer
from views.employees_requests import get_all_employees, get_single_employee
from views.location_requests import get_all_locations, get_single_location
@@ -77,6 +79,24 @@ class HandleRequests(BaseHTTPRequestHandler):
response = f"{get_all_animals()}"
self.wfile.write(response.encode())
if resource == "locations":
if id is not None:
response = f"{get_single_location(id)}"
else:
response = f"{get_all_locations()}"
self.wfile.write(response.encode())
if resource == "employees":
if id is not None:
response = f"{get_single_employee(id)}"
else:
response = f"{get_all_employees()}"
self.wfile.write(response.encode())
# Here's a method on the class that overrides the parent's method.
# It handles any POST request.