router.tpl 736 Bytes
Newer Older
wanli's avatar
wanli committed
1 2 3 4
# -*- coding: utf-8 -*-

from flask import Blueprint
from flask_restful import Api
wanli's avatar
wanli committed
5 6 7
{%- for item in config %}
from . import {{item["name"]}}
{%- endfor %}
wanli's avatar
wanli committed
8 9 10 11 12

api_v1 = Blueprint('api_v1', __name__)

api = Api(api_v1)

wanli's avatar
wanli committed
13 14 15
{% for item in config %}
api.add_resource({{ item['name'] }}.{{ item['name'] | letterUpper }}Resource, '/{{ item['name'] }}{{ item['view']['get']['path'] }}'{% if item['view']['get']['endpoint'] %}, endpoint={{ item['view']['get']['endpoint'] }}{% endif %})
api.add_resource({{ item['name'] }}.{{ item['name'] | letterUpper }}ResourceList, '/{{ item['name'] }}{{ item['view']['getList']['path'] }}'{% if item['view']['getList']['endpoint'] %}, endpoint='{{ item['view']['getList']['endpoint'] }}'{% endif %})
wanli's avatar
wanli committed
16
{% endfor %}