1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
from flask import g
from pyaggr3g470r.controllers import ArticleController
from pyaggr3g470r.views.api.common import PyAggResourceNew, \
PyAggResourceExisting, \
PyAggResourceMulti
ARTICLE_ATTRS = {'title': {'type': str},
'content': {'type': str},
'link': {'type': str},
'date': {'type': str},
'feed_id': {'type': int},
'like': {'type': bool},
'readed': {'type': bool}}
class ArticleNewAPI(PyAggResourceNew):
controller_cls = ArticleController
attrs = ARTICLE_ATTRS
class ArticleAPI(PyAggResourceExisting):
controller_cls = ArticleController
attrs = ARTICLE_ATTRS
class ArticlesAPI(PyAggResourceMulti):
controller_cls = ArticleController
attrs = ARTICLE_ATTRS
g.api.add_resource(ArticleNewAPI, '/article', endpoint='article_new.json')
g.api.add_resource(ArticleAPI, '/article/<int:obj_id>',
endpoint='article.json')
g.api.add_resource(ArticlesAPI, '/articles', endpoint='articles.json')
|