
Implemented: - Basic arithmetic operations (add, subtract, multiply, divide) - Input validation - SQLite database with SQLAlchemy - Alembic migrations - Health endpoint generated with BackendIM... (backend.im)
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 endpointPOST /api/add
: Add two numbersPOST /api/subtract
: Subtract second number from first numberPOST /api/multiply
: Multiply two numbersPOST /api/divide
: Divide first number by second number
Setup and Running
-
Install dependencies:
pip install -r requirements.txt
-
Run the application:
uvicorn main:app --reload
-
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.
Description
Languages
Python
94%
Mako
6%