Python REST API for simple calculations, made with Django REST Framework
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Python 3.8.x
Create virtual environment inside project
virtualenv -p python env
Activate virtual envirnment
source env/bin/activate
Install all dependencies
pip install -r requirements.txt
Running local server in directory where is manage.py file (second calculateAPI folder)
python manage.py runserver <port-number>
In order to stop server press Ctrl+C
In order to login as admin go to: http://127.0.0.1:6767/admin/
Admin user:
username: admin
password: 123456789
Basic user:
username: test_user_1
password: 123456789nc
expects either Array of integers (comma-separated integers) or one integer as the body of the POST request.
calculates the sum of all elements that exist in the array, saves it and returns it. If parameter all is provided, then call returns all calculated sums.
saves array and calculations, give it some ID, and empties array and all calculations from memory.
returns JSON with the next structure:
[{“id”: <id of element>, “array”: <array of numbers>, “calculations”: <array of all calculations for given array of numbers>} …]
if parameter id is provided call returns just JSON for that id.
{“id”: <id of element>, “array”: <array of numbers>, “calculations”: <array of all calculations for given array of numbers>}
In order to test whole flow of the app run
python manage.py test
File that will be run with this command is inside calculateApi/main/tests.py
- Python - Programming language (3.8.0)
- Django - The web framework used (3.0.5)
- Django REST Framework - REST framework (3.11.0)
- Postman - Tool for making HTTP requests