Browse Source

improvements to API

joel
Simon Bowie 1 year ago
parent
commit
4514a4b25f
2 changed files with 7 additions and 7 deletions
  1. +3
    -3
      web/app/api.py
  2. +4
    -4
      web/app/templates/api.html

+ 3
- 3
web/app/api.py View File

@@ -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 View File

@@ -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…
Cancel
Save