Commits

Yang Zhang committed 38a33fa

make JsonProxy to avoid jsonify unnecessary attributes

  • Participants
  • Parent commits eb3fba4

Comments (0)

Files changed (1)

                                 mimetype='application/json')
     return inner
 
+class JsonProxy:
+    pass
+
+
 @app.route('/api/json/booklist/<int:listid>')
 @jsonify
 def get_listbook(listid):
     books = Book.get_jsonify_books(offset = listid-1)
+    proxys = []
     for book in books:
-        book.cover_image = base64.b64encode(book.cover_image)
-    return {'content':books}
+        proxy = JsonProxy()
+        proxy.name = book.name
+        proxy.author = book.author
+        proxy.intro = book.intro
+        proxy.id = book.id
+        proxys.append(proxy)
+    return {'content':proxys}
 
 @app.route('/api/json/chapters/<int:bookid>')
 @jsonify
 def get_pagelist(chapterid):
     pages = Chapter.get_jsonify_pages_bychaperid(chapterid)
     return {'content':pages,'length':len(pages)}
-    
+
 
 '''test'''
 @app.route('/test')