Spaces:
Sleeping
Sleeping
A newer version of the Gradio SDK is available:
5.42.0
metadata
title: Calculator App
emoji: 🔢
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 4.19.2
app_file: app.py
pinned: false
Calculator Application
A simple calculator application built with Gradio and FastAPI.
Features
- Addition
- Subtraction
- Multiplication
- Division
- Clean and intuitive user interface
- Error handling for invalid operations
How to Use
- Enter two numbers in the input fields
- Select the operation you want to perform
- Click the "Calculate" button
- View the result in the output field
Tech Stack
- Frontend: Gradio 4.19.2
- Backend: FastAPI
- Data Validation: Pydantic
Setup
- Clone the repository:
git clone https://github.com/NikhilSetiya/calculator-app.git
cd calculator-app
- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Start the backend server:
python backend.py
- In a new terminal, start the frontend:
python frontend.py
- Open your web browser and navigate to the URL shown in the Gradio output (typically http://localhost:7860)
API Documentation
Once the backend server is running, you can access the API documentation at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
Usage
- Enter two numbers in the input fields
- Select the operation you want to perform
- Click the "Calculate" button
- View the result in the output field
Error Handling
The application handles various error cases:
- Division by zero
- Invalid operations
- Network errors
- Input validation
Contributing
Feel free to submit issues and enhancement requests!
License
This project is licensed under the MIT License - see the LICENSE file for details.