Archived
save completed ch. 3 work (not tested)
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user