Giter Club home page Giter Club logo

calculator-api-flask's Introduction

Calculator-API-Flask

Addition, subtraction, division and multiplication of two numbers

App structure

  • cal.py: includes 4 endpoints, explain in Endpoints section
  • cal_eval.py: includes only 1 endpoint, explain in Endpoints section

Getting started

Prerequisites

To run this project, an environment with Python 3.7 and Flask is required

Using this project

Clone the repo

git clone https://github.com/minhtanngo/Calculator-API-Flask.git

Access the project directory

cd Calculator-API-Flask

Inside the project directory, execute the following:

  • To use the cal.py
set FLASK_APP=cal.py 
flask run
  • To use the cal_eval.py
set FLASK_APP=cal_eval.py 
flask run

You should see something like this if you configured correctly:

 * Serving Flask app "cal.py"
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

Endpoints

The webservice has the following endpoints:

  • Add two numbers and return the result
POST: /add
  • Subtract two numbers and return the result
POST: /sub
  • Divide two numbers and return the result
POST: /div
  • Multiply two numbers and return the result
POST: /mult

The endpoints can be tested with the following body and URLs:

POST Body:
{"n1":5, "n2":10}

URLs:
http://localhost:5000/add
http://localhost:5000/sub
http://localhost:5000/div
http://localhost:5000/mult

calculator-api-flask's People

Contributors

minhtanngo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.