Last active
July 8, 2022 11:53
-
-
Save an01f01/bd078a56a43e3a0bf87225596b382003 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BooksHandler(BaseHandler): | |
""" | |
GET handler for fetching all books from the database | |
""" | |
@gen.coroutine | |
def get(self): | |
self.set_status(200) | |
self.write({'message': 'All books sorted by title', 'books': []}) | |
self.finish() | |
""" | |
POST handler for adding a new book to the database | |
""" | |
@gen.coroutine | |
def post(self): | |
book_json = self.request.body.decode('utf-8') | |
book_json = tornado.escape.json_decode(book_json) | |
self.set_status(200) | |
self.write({'message': 'Book with id ' + params['id'], 'book': {}}) | |
self.finish() | |
class BookHandler(BaseHandler): | |
""" | |
GET handler for fetching a specified book from the database | |
""" | |
@gen.coroutine | |
def get(self, **params): | |
self.set_status(200) | |
self.write({'message': 'Book with id' params['id'], 'book': {}}) | |
self.finish() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment