I update the do_GET function in the request_handler.py
I set the response = {}
I imported the get_single_category and get_all_categories to the request_handler.py
In the request handler, set an if condition that will render a single category or all categories and give a 200 success code or a 404 error code depending on the query
I then set json to dump the response
For ticket #19
-I imported sqlite3 and the Category class from models
in the category_requests.py I created the get_all_categories function that connects the db.sqlite3 and injected the variable's value into the SQL statement
initialized an empty category list
converted the rows of data into a python list
iterated the list of data that got returned
in the iteration created a category instance from the current row, using the exact order specified in the parameters defined in the category class
appended the dictionary
and returned the category
I imported the get_all_categories function to the init.py in views
For ticket #21
in the category_requests.py I created the get_single_category function that connects the db.sqlite3 and injected the variable's value into the SQL statement
loaded the single result into memory
created a category instance form the current row
returned the category dictionary
How has this been tested?
[ ] from github pull the down the branch acd
[ ] open your debugger
[ ] open postman
[ ] in the query in postman, be sure you are creating a GET request
Ticket
37 #21 #19
Description
For ticket #37
For ticket #19
-I imported sqlite3 and the Category class from models
For ticket #21
How has this been tested?