1- Spin up backend docker container by running:
$ docker-compose up
2- Navigate API using Swagger UI by visiting the URL below
http://localhost:5000/swagger/
- clone this repo
$ git clone https://github.com/toubar/flask-app backend
- create python virtual environement
$ python -m venv venv
- install dependencies
$ venv/bin/pip install -r requirements.txt
- activate virtualenv
$ source venv/bin/activate
- add Flask env variables
$ export FLASK_APP="main.py"
$ export FLASK_ENV="development"
$ export FLASK_DEBUG=True
- spin up flask server
$ venv/bin/python -m flask run
GET Services
curl --request GET \
--url http://127.0.0.1:5000/service
POST Auth (for JWT token)
curl --request POST \
--url http://127.0.0.1:5000/authenticate \
--header 'authorization: Bearer undefined' \
--header 'content-type: application/json' \
--data '{
"jwt_secret": "jwt_secret"
}'
PUT Service (new) -- get JWT token from Auth endpoint
curl --request PUT \
--url http://127.0.0.1:5000/services \
--header 'authorization: Bearer <<<PUT JWT TOKEN HERE>>>' \
--header 'content-type: application/json' \
--data '{
"service": "New Service",
"ip": "10.12.99.264",
"servers": [
{
"name": "lin-brn-891",
"status": "running"
},
{
"name": "lin-brn-125",
"status": "error"
},
{
"name": "lin-brn-711",
"status": "running"
},
{
"name": "lin-brn-999",
"status": "running"
}
]
}'
assuming venv is activated...
$ cd services/tests
# run tests
$ python -m pytest