Create an endpoint to return the prime numbers from a list. Test are out of the scope.
-
Method Allowed:
POST, OPTIONS
-
Body format:
{"numbers": [\<list of numbers\>]}
-
Response format:
{"prime_numbers": [\<list of prime numbers\>]}
if the request is successful{"error": "error message"}
if the request is not successful- method not allowed (
405
) if the method is not POST or OPTIONS
-
Body example:
{"numbers": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]}
-
Response example:
{"prime_numbers": [2, 3, 5, 7]}
- Clone the repository
- Create a virtual environment using poetry
- Install the dependencies
poetry shell poetry install
- Run the project
python manage.py runserver
- Access the endpoint using the browser or a tool like Postman
It is build using django rest framework, so you can use the browsable api from the directly from the browser.