Service to manage drones
Language
Python
framework
Flask
Database
Mongodb (running locally)
API test platform
postman
prerequisites & required installations
Python3
Mongodb
Postman
This API allows the client to.
- registering a drone.
- loading a drone with medication items.
- checking loaded medication items for a given drone.
- checking available drones for loading.
- check drone battery level for a given drone.
This service uses random
a python library to generate Data for various variables used in the project. It also assigns different states to newly created drone and also assigning battery charge value.
This data is then consumed by the API in JSON form and fed to the database. Using Postman, the required data can be fetched/updated using the same data
format(JSON)
IDE used VSCODE
- To run MongoDb open terminal and type
mongo start
- Open folder containing the file task_Drone.py on yout IDE(I used VSCODE)
- Open terminal on VsCode by pressing
Ctrl+
. (help in displaying vital information when the program is running) - Click Run button.
open Postman and type the following commands to test the API.
Select POST method then type http://localhost:5000/add
on the URL bar, Click SEND to send the request. You shoud be ble to see a success message.
Select PUT method then type http://localhost:5000/add-load
on the Url bar, Click SEND to execute the request.
Every time a drone is loaded its state changes from IDLE to LOADING.
fig 2.1 Loading drone that is not at IDLE state
Select GET method and type http://localhost:5000/get-med/<id>
on the url bar. Replace with the actual id of the drone you want to check. and
click SEND The API will filter out the fields containing information about medication loaded to that drone.
This method filters out those drones that are IDLE and have Charge of more than 25%. Select GET method and type
http://localhost:5000/available
on the url bar and click SEND. In this case there was only one drone that was IDLE
However after adding more drones to the fleet I got another IDLE drone with a healthy battery.
Select GET method and type hhttp://localhost:5000/get-battery/<id>
on the url bar. Replace with the actual id of the drone you want to check. and
click SEND.