A rest API allowing to post devices, set their location and get the location of a device. Implemented in python 3.8 using flask and sqlAlchemy with sqlite.
Steps to run the project:
- Pull the repository
git clone https://github.com/Johanpdrsn/RadioPy.git
- Navigate to directory
- Build docker image
docker build --rm --pull -f "./Dockerfile" -t "radiopy:latest" .
- Run the container
docker run --rm -d -p 5000:5000/tcp radiopy:latest
Example use of the api:
-
Add device
http://localhost:5000/radios/100
POST with payload{ "alias": "Radio100", "allowed_locations": ["CPH-1", "CPH-2"] }
This will return 201 CREATED and the added device.
-
Set location
http://localhost:5000/radios/100/location
POST with payload{ "location": "CPH-1" }
Returns 200 OK.
-
Get location
http://localhost:5000/radios/100/location
GET. Returns 200 OK and the location.