kakedari / flask-calculator-demo

This is Flask API for Demo Calculator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

# Flask Calculator

This is a simple Flask web application that provides a user interface for performing basic arithmetic calculations. Users can select the operation (addition, subtraction, multiplication, or division) from a dropdown menu, input two numbers, and see the result.

## Getting Started

### Prerequisites

- Python (version 3.x)
- Flask (install using `pip install Flask`)

### Running the Application

1. Clone the repository:

   ```bash
   git clone https://github.com/your-username/flask-calculator.git
  1. Navigate to the project directory:

    cd flask-calculator
  2. Run the Flask app:

    python app.py

    The app will be accessible at http://127.0.0.1:5000/ in your web browser.

How to Use

  1. Open the web application in your browser.

  2. Select the desired operation from the dropdown menu.

  3. Enter two numbers in the respective input fields.

  4. Click the "Calculate" button.

  5. The result of the calculation will be displayed below the form.

Supported Operations

  • Addition
  • Subtraction
  • Multiplication
  • Division

API Endpoint

The calculations can also be performed programmatically using the following API endpoint:

  • Endpoint: /calculate
  • Method: POST
  • Parameters:
    • operation (string): The operation to perform (add, subtract, multiply, divide).
    • num1 (float): The first number.
    • num2 (float): The second number.

Example curl command for addition:

curl -X POST -F "operation=add" -F "num1=5" -F "num2=3" http://127.0.0.1:5000/calculate

Troubleshooting

  • If you encounter issues, check the console where the Flask app is running for error messages.

About

This is Flask API for Demo Calculator


Languages

Language:HTML 54.9%Language:Python 45.1%