Skip to content

A Mathematical Web Service which calculates and provides results of Fibonacci, Ackermann and Factorial algorithms

Notifications You must be signed in to change notification settings

redrussianarmy/mathematical-web-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mathematical Web Service

Python 3.10.1

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.


Tasks

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.

  • Environment Preparation

    The necessary environment can be created by selecting the Prepare Environment option.

    Untitled

  • Unit Tests and Coverage

    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.

    image

    When the task is completed, you can find coverage rates by opening index.html in the coverage-report folder.


Launch

  • Run Server

    • [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 the Run and Debug menu.

      image

    • [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
      
  • Run Unit Tests

    • If you are using VSCode, the unit tests can be run if you select the Run UT Web Service option from the Run and Debug menu.

      image

    • 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
      

Query Examples

  • Fibonacci Algorithm

    GET query string request:

    http://127.0.0.1:8000/api/fibonacci/?n=6
    

    Response:

    {
      "result": 8
    }
    
  • Ackermann Algorithm

    GET query string request:

    http://127.0.0.1:8000/api/ackermann/?m=1&n=3
    

    Response:

    {
      "result": 5
    }
    
  • Factorial Algorithm

    GET query string request:

    http://127.0.0.1:8000/api/factorial/?n=6
    

    Response:

    {
      "result": 720
    }
    

How to Deploy the Application to AWS Elastic Beanstalk

You can reach the official article on how to deploy this application to Elastic Beanstalk by clicking the link below.

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html#python-django-configure-for-eb

About

A Mathematical Web Service which calculates and provides results of Fibonacci, Ackermann and Factorial algorithms

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published