RESTful API for the HospitalWaiter Patient and Staff applications to interface with a SQL database.
It is best to run the microservice using a virtual Python environment (virtualenv
). The following steps assume the creation of a virtual python environment
- Clone this repository into your document root folder for your web server.
- Create a Python virtual environment by using the
virtualenv
command (eg.virtualenv venv
) - Start the virtual environment.
- From the command-line, run
pip install -r requirements.txt
. This will install all required dependencies. - Set the following environment variables using the
SET
command:- SECRET_KEY - The secret key used for token authentication. This should be the same secret key used for the SSO microservice.
- MAIL_USER - The username of the server's email
- MAIL_PASSWORD - Email password.
- DATABASE_URL - The URL of the database to interface with. This should include the schema, host, port and password where applicable.
- Set the FLASK_APP environment variable to "MealService.py".
- Run the following command:
flask run -p [PORT]
(where[PORT]
is the port from which to run the microservice. This defaults to 5000 but may need to change if multiple microservices are running from the same machine). This will start the server.
The following endpoints are available:
Endpoint URL | Available actions |
---|---|
/mealservice/meal |
GET, POST |
/mealservice/meal/<id> |
GET, PUT, DELETE |
/mealservice/meal/<id>/patient |
GET |
/mealservice/meal/<id>/requirement |
GET, POST |
/mealservice/meal/<id>/requirement/<id> |
DELETE |
/mealservice/patient |
GET, POST |
/mealservice/patient/<id> |
GET, PUT, DELETE |
/mealservice/patient/<id>/requirement |
GET, POST |
/mealservice/patient/<id>/requirement/<id> |
DELETE |
/mealservice/patient/<id>/meal |
GET, POST |
/mealservice/patient/<id>/meal/<id> |
DELETE |
/mealservice/requirement |
GET, POST |
/mealservice/requirement/<id> |
GET, PUT, DELETE |
/mealservice/requirement/<id>/meal |
GET |
/mealservice/requirement/<id>/patient |
GET |
All of the above endpoints require an Authorization header containing a token generated by the HospitalWaiter SSO microservice.