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

# route for exporting all users in database # route for exporting all users in database
@api.route('/api/users') @api.route('/api/users')
@login_required @login_required
def get_users():
def get_users_json():
users = User.query.all() users = User.query.all()
users_schema = UserSchema(many=True) users_schema = UserSchema(many=True)
result = users_schema.dump(users) result = users_schema.dump(users)


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


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

+ 4
- 4
web/app/templates/api.html View File

{% block content %} {% block content %}


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


<br><br> <br><br>


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


<br><br> <br><br>


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


<br><br> <br><br>


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


<br><br> <br><br>



Loading…
Cancel
Save