FlightFuelRESTApi is a RESTful API developed to optimize and manage airplane fuel consumption and flight capacities. Utilizing Django and Django REST Framework, this project adheres to RESTful principles, offering a scalable and efficient way to calculate fuel requirements and flight durations based on varying airplane and passenger configurations.
- Python 3.8 or later
- pip (Python package installer)
- Clone The Repository:
git clone https://github.com/SyedHassanUlHaq/FlightFuelRESTApi.git
cd FlightFuelRESTApi/kami_airlines
- Run Migrations:
python manage.py makemigrations
python manage.py migrate
- Start The Server:
python manage.py runserver
-
Create Airplane:
- POST
/api/airplanes/
- Input:
{ "airplane_id": int, "passengers": int }
- Output: Details including fuel consumption and max minutes able to fly.
- For Example:
curl -X POST http://localhost:8000/api/airplanes/ -d "airplane_id=2&passengers=90"
- Input:
- POST
-
List Airplanes:
- GET
/api/airplanes/
- Output: List of all airplanes with their details.
- For Example:
curl http://localhost:8000/api/airplanes/
- GET
- Create Airplane:
curl -X POST http://localhost:8000/api/airplanes/ -d "airplane_id=1&passengers=100"
To list all airplanes, use the following curl
command:
curl http://localhost:8000/api/airplanes/
To run the tests and generate a coverage report, follow these steps:
Execute the following command to run the tests:
python manage.py test
First, ensure you have coverage installed. If not, install it using pip:
pip install coverage
Then, run the tests with coverage measurement:
coverage run --source='.' manage.py test
coverage report