Automated Action 5ca82943e6 Create Calculator API with FastAPI
Implemented:
- Basic arithmetic operations (add, subtract, multiply, divide)
- Input validation
- SQLite database with SQLAlchemy
- Alembic migrations
- Health endpoint

generated with BackendIM... (backend.im)
2025-05-14 00:04:55 +00:00

43 lines
1.0 KiB
Markdown

# Calculator API
This is a FastAPI-based calculator API that provides basic arithmetic operations.
## Features
- Basic arithmetic operations: addition, subtraction, multiplication, division
- Input validation
- Results stored in SQLite database
- Health check endpoint
- OpenAPI documentation
## API Endpoints
- `GET /health`: Health check endpoint
- `POST /api/add`: Add two numbers
- `POST /api/subtract`: Subtract second number from first number
- `POST /api/multiply`: Multiply two numbers
- `POST /api/divide`: Divide first number by second number
## Setup and Running
1. Install dependencies:
```
pip install -r requirements.txt
```
2. Run the application:
```
uvicorn main:app --reload
```
3. Access the API documentation:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
## Database
The application uses SQLite as the database, storing calculation history. The database file is located at `/app/storage/db/db.sqlite`.
## Migrations
Database migrations are managed with Alembic.