
- Set up FastAPI application structure - Implemented SQLite database integration with SQLAlchemy - Added Alembic migrations for database versioning - Created bet model and API endpoints for CRUD operations - Added comprehensive README with setup and usage instructions - Added health check endpoint and CORS support
55 lines
1.4 KiB
Python
55 lines
1.4 KiB
Python
from typing import Any, Dict, Optional
|
|
|
|
from fastapi import HTTPException, status
|
|
|
|
|
|
class NotFoundException(HTTPException):
|
|
def __init__(
|
|
self,
|
|
detail: str = "Item not found",
|
|
headers: Optional[Dict[str, Any]] = None,
|
|
) -> None:
|
|
super().__init__(
|
|
status_code=status.HTTP_404_NOT_FOUND,
|
|
detail=detail,
|
|
headers=headers,
|
|
)
|
|
|
|
|
|
class BadRequestException(HTTPException):
|
|
def __init__(
|
|
self,
|
|
detail: str = "Bad request",
|
|
headers: Optional[Dict[str, Any]] = None,
|
|
) -> None:
|
|
super().__init__(
|
|
status_code=status.HTTP_400_BAD_REQUEST,
|
|
detail=detail,
|
|
headers=headers,
|
|
)
|
|
|
|
|
|
class UnauthorizedException(HTTPException):
|
|
def __init__(
|
|
self,
|
|
detail: str = "Not authenticated",
|
|
headers: Optional[Dict[str, Any]] = None,
|
|
) -> None:
|
|
super().__init__(
|
|
status_code=status.HTTP_401_UNAUTHORIZED,
|
|
detail=detail,
|
|
headers=headers,
|
|
)
|
|
|
|
|
|
class ForbiddenException(HTTPException):
|
|
def __init__(
|
|
self,
|
|
detail: str = "Not enough permissions",
|
|
headers: Optional[Dict[str, Any]] = None,
|
|
) -> None:
|
|
super().__init__(
|
|
status_code=status.HTTP_403_FORBIDDEN,
|
|
detail=detail,
|
|
headers=headers,
|
|
) |