This is a web service which calculates and provides results for the following algorithms via a REST API:
- The n:th Fibonacci number F(n) with the value of n provided by the user.
- The Ackermann function A(m,n) with values of m and n provided by the user.
- The factorial n! of a non-negative integer n provided by the user.
If you are using VSCode, the tasks config file was created in the .vscode file. When you press CTRL+SHIFT+B
, you will see the following options.
-
The necessary environment can be created by selecting the
Prepare Environment
option. -
A report that shows how much of the written code is covered by the unit tests can be created by selecting the
Unit Tests and Coverage
option.When the task is completed, you can find coverage rates by opening
index.html
in thecoverage-report
folder.
-
-
[OPT1] If you have docker installed on your computer, run the following commands in order.
docker build -t web-service:1.0 .
docker run -p 8000:8000 web-service:1.0
-
[OPT2] If you are using VSCode, the application can be started if you select the
Run Web Service
option from theRun and Debug
menu. -
[OPT3] If you are going to run the application from the terminal, you can type the following command. Make sure you are on the same path as the manage.py file.
py manage.py runserver
-
-
-
If you are using VSCode, the unit tests can be run if you select the
Run UT Web Service
option from theRun and Debug
menu. -
If you are going to run the unit tests from the terminal, you can type the following command. Make sure you are on the same path as the manage.py file.
py manage.py test algorithms.tests
-
-
GET query string request:
http://127.0.0.1:8000/api/fibonacci/?n=6
Response:
{ "result": 8 }
-
GET query string request:
http://127.0.0.1:8000/api/ackermann/?m=1&n=3
Response:
{ "result": 5 }
-
GET query string request:
http://127.0.0.1:8000/api/factorial/?n=6
Response:
{ "result": 720 }
You can reach the official article on how to deploy this application to Elastic Beanstalk by clicking the link below.