# 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
-
Navigate to the project directory:
cd flask-calculator
-
Run the Flask app:
python app.py
The app will be accessible at
http://127.0.0.1:5000/
in your web browser.
-
Open the web application in your browser.
-
Select the desired operation from the dropdown menu.
-
Enter two numbers in the respective input fields.
-
Click the "Calculate" button.
-
The result of the calculation will be displayed below the form.
- Addition
- Subtraction
- Multiplication
- Division
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
- If you encounter issues, check the console where the Flask app is running for error messages.