This application is a simple REST API made in Django.
It's using HTTP methods to do various operations in database.
To run it You have to install Django 4.0 and "requests" library.
App Name: Vehicle
To start application locally type in terminal: python3 manage.py runserver
If exists: The given model and maker will be saved in local database.
Else: It will return an error (404).
Local example:
curl -X POST -H "Content-Type: application/json" -d '{"make":"Honda", "model":"del Sol"}' http://127.0.0.1:8000/vehicle/cars
Heroku example:
curl -X POST -H "Content-Type: application/json" -d '{"make":"Honda", "model":"del Sol"}' https://simple-rest-api.herokuapp.com/vehicle/cars It will check if vehicle with a given id exists in local database.
If exists: Vehicle with a given id will be delete from database.
Else: It will return an error (404).
Local example:
curl -X DELETE http://127.0.0.1:8000/vehicle/delete/15/
Heroku example:
curl -X DELETE https://simple-rest-api.herokuapp.com/vehicle/delete/15/ It will check if vehicle with a given id exists in local database.
If exists: Number of rates will be incremented by one and average rating will be recalculated for new value.
Else: It will return an error (404).
Local example:
curl -X POST -H "Content-Type: application/json" -d '{"car_id":10, "rating":2}' http://127.0.0.1:8000/vehicle/rate
Heroku example:
curl -X POST -H "Content-Type: application/json" -d '{"car_id":10, "rating":2}' https://simple-rest-api.herokuapp.com/vehicle/rate It will return list of all cars from local database
Local example:
curl -X GET http://127.0.0.1:8000/vehicle/cars
Heroku example:
curl -X GET https://simple-rest-api.herokuapp.com/vehicle/cars It will return list of all cars from local database ordered by number of rates in descending order
Local example:
curl -X GET http://127.0.0.1:8000/vehicle/popular
Heroku example:
curl -X GET https://simple-rest-api.herokuapp.com/vehicle/popular