/prime-number-generator

A restful service that generates prime numbers in given range

Primary LanguagePython

Prime-number-generator

This repository contain a RESTful Flask API for generating prime numbers in range. I used sqlalchemy as ORM for this API, along with SQLite DB.

Prerequisites

To run this API you will need Python 3.8 along with below liabraries installed

  • Flask==1.1.2
  • flask-marshmallow==0.14.0
  • Flask-SQLAlchemy==2.5.1
  • Jinja2==2.11.2
  • marshmallow==3.13.0
  • SQLAlchemy==1.4.22

Usage

Before using API you need to create DB : flask db_create

Step-1) Run app.py : Python app.py
Step-2) Use following endpoints for requests .It will return a JSON .

  • Home Route (GET) : http://127.0.0.1:5000/
  • Method-1 (Naive) (POST) : http://127.0.0.1:5000/cal/1/start/end
  • Method-2 (Sieve of Eratosthenes) (POST) : http://127.0.0.1:5000/cal/2/start/end
    Note: Please provide positive integers start and end
  • Get all records (GET) : http://127.0.0.1:5000/records
  • Clear records from database (DELETE) : http://127.0.0.1:5000/clear
    Please clear DB once you done using

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D