瀏覽代碼

improvements to API

joel
Simon Bowie 1 年之前
父節點
當前提交
4514a4b25f
共有 2 個檔案被更改,包括 7 行新增7 行删除
  1. +3
    -3
      web/app/api.py
  2. +4
    -4
      web/app/templates/api.html

+ 3
- 3
web/app/api.py 查看文件

@@ -40,7 +40,7 @@ def api_page():
# route for exporting all users in database
@api.route('/api/users')
@login_required
def get_users():
def get_users_json():
users = User.query.all()
users_schema = UserSchema(many=True)
result = users_schema.dump(users)
@@ -57,14 +57,14 @@ def get_tools_json():

# route for exporting all practices in database
@api.route('/api/practices')
def get_practices():
def get_practices_json():
resource_type = 'practice'
output = get_resource_json(resource_type)
return output

# route for exporting all books in database
@api.route('/api/books')
def get_books():
def get_books_json():
resource_type = 'book'
output = get_resource_json(resource_type)
return output

+ 4
- 4
web/app/templates/api.html 查看文件

@@ -1,18 +1,18 @@
{% block content %}

<a href="/api/users">Users</a> (login required)
<a href="{{ url_for('api.get_users_json') }}">Users</a> (login required)

<br><br>

<a href="/api/tools">Tools</a>
<a href="{{ url_for('api.get_tools_json') }}">Tools</a>

<br><br>

<a href="/api/practices">Practices</a>
<a href="{{ url_for('api.get_practices_json') }}">Practices</a>

<br><br>

<a href="/api/books">Books</a>
<a href="{{ url_for('api.get_books_json') }}">Books</a>

<br><br>


Loading…
取消
儲存