- Create .env.example for environment variables - Update README with project structure and development setup instructions - Implement FastAPI application with API routes for scenarios and parameters - Add database models for scenarios, parameters, and simulation results - Introduce validation middleware for JSON requests - Create services for running simulations and generating reports - Add testing strategy and directory structure in documentation
24 lines
685 B
Python
24 lines
685 B
Python
from fastapi import APIRouter, HTTPException, Depends
|
|
from typing import Dict, Any
|
|
|
|
from services.reporting import generate_report
|
|
from sqlalchemy.orm import Session
|
|
from config.database import SessionLocal
|
|
|
|
router = APIRouter(prefix="/api/reporting", tags=["Reporting"])
|
|
|
|
def get_db():
|
|
db = SessionLocal()
|
|
try:
|
|
yield db
|
|
finally:
|
|
db.close()
|
|
|
|
@router.post("/summary", response_model=Dict[str, float])
|
|
async def summary_report(results: Any):
|
|
# Expect a list of simulation result dicts
|
|
if not isinstance(results, list):
|
|
raise HTTPException(status_code=400, detail="Invalid input format")
|
|
report = generate_report(results)
|
|
return report
|