iot.py 334 B

123456789101112131415
  1. from fastapi import FastAPI, Request
  2. from fastapi.responses import JSONResponse
  3. app = FastAPI()
  4. class MissingIOTDataError(Exception):
  5. pass
  6. async def missing_data_exception_handler(request: Request, exc: MissingIOTDataError):
  7. return JSONResponse(
  8. status_code=400,
  9. content={"message": "Missing data"}
  10. )