This project contains a simple Django application exposing API endpoints for basic arithmetic operations.
All endpoints are prefixed with /api/ and accept query parameters a and b.
/api/add/– returns the sum ofaandb./api/subtract/– returns the difference betweenaandb./api/multiply/– returns the product ofaandb./api/divide/– returns the quotient ofadivided byb(error ifbis zero).
Example request:
curl "http://localhost:8000/api/add/?a=1&b=2"
Response:
{"result": 3.0}
-
Install dependencies:
pip install django
-
Run migrations and start the development server:
python manage.py migrate python manage.py runserver
Then access the endpoints at http://localhost:8000/api/.