To run the demo application you need:
Python 3.7 pip install the included requirements.txt SQLite3, SQLite 3, effectively any version should work.
To run the application start it after installing the requirements with:
On Windows:
set FLASK_APP=demo_app
On Linux:
export FLASK_APP=demo_app
flask init-db
flask run --host=0.0.0.0 --port=8080
Alternatively, a Dockerfile is provided.
As a UI user I can:
- Register through web portal
- Review my own user information from the main view
As an API Consumer I can:
- Register new users
- Review users registered in system
- If authenticated I can get personal information of users
- If authenticated I can update personal information of users
The Application exposes a simple API with the following routes:
Route | Methods | Authentication |
---|---|---|
/api/auth/token | GET | Basic |
/api/users | GET | Token |
/api/users | POST | None |
/api/users/{username} | GET, PUT | Token |
Your request headers should set at minimum:
'Content-Type': 'application/json'
Access to users information requires a Token based authentication.
To receive a token perform basic authentication against /api/auth/token
using the username/password you registered with in the Web interface.
For example:
>>> curl -u username:1234 http://localhost:8080/api/auth/token
{
"status": "SUCCESS",
"token": "MzMyNjQyMzAzODMwNjk1Mzg1MDU4OTA3MTEyMDM3MTQ2NDg5Mzg2"
}
For subsequent accesses to endpoints requiring a token update your request headers to include it:
'Content-Type': 'application/json'
'Token': 'MzMyNjQyMzAzODMwNjk1Mzg1MDU4OTA3MTEyMDM3MTQ2NDg5Mzg2'
All API calls respond in the following scheme:
{'status': 'SUCCESS/FAILURE',
'message': 'human readable message',
'payload': {...}}
Subject information can be updated by sending PUT requests with a simple payload like:
{'datapoint1': 'value',
'datapoint2': 'value',
...}