Simple .NET 8 Web API that evaluates math expressions, stores request/response in a SQLite DB, and lets you query expressions by the result.
- Controllers/CalculateController.cs
- Data/AppDbContext.cs
- Models/ExpressionHistory.cs
- Program.cs
- appsettings.json
- ExpressionCalculatorAPI.csproj
- Open in Codespaces or clone locally.
- Restore packages:
dotnet restore - From project folder:
dotnet run - Open Swagger at
/swaggerto test endpoints.
POST /api/calculate— body: raw JSON string, e.g."3+4*6-12"GET /api/calculate?result={value}— returns expressions with that result
- Uses SQLite
expressions.dbin project folder. - Input is validated to allow digits, whitespace, parentheses, and operators
+-*/.only. If you need functions (sin, cos) remove validation or extend.