python class BookResource(ResourceBase): type = 'books' id = fields.IntegerField() title = fields.TextField() author = fields.TextField() python class BookResource(ResourceBase): # ... def create(self, *args, **kwargs): pass def update(self, *args, **kwargs): pass python router = TornadoRouterBuilder() router.register_resource(BookResource) app = Application([(r'/api/books/(\d+)', router.get_route('/books/:id'))]) python class BookSchema(Schema): class Meta: type_ = 'books' book = Book(title='Python Cookbook', author='David Beazley') serialized_data = BookSchema().dump(book)


上一篇:
下一篇:
切换中文