todoapp-us6a2a/app/api/v1/env_vars.py
Automated Action 1df01b998d Add endpoint to read CONTENT environment variable
- Created a new endpoint at /api/v1/env/content that returns the CONTENT environment variable
- Added error handling for when the environment variable is not set
- Updated documentation with new endpoint information and usage examples
- Added environment variables as a new feature in README
2025-05-31 21:31:18 +00:00

33 lines
882 B
Python

import os
from typing import Dict
from fastapi import APIRouter, HTTPException, status
router = APIRouter()
@router.get(
"/env/content",
response_model=Dict[str, str],
summary="Get content from CONTENT environment variable",
description="Returns the value of the CONTENT environment variable"
)
def get_content_env_var():
"""
Retrieve the value of the CONTENT environment variable.
Returns:
dict: A dictionary containing the CONTENT environment variable value
Raises:
HTTPException: If the CONTENT environment variable is not set
"""
content_value = os.environ.get("CONTENT")
if content_value is None:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail="CONTENT environment variable is not set"
)
return {"content": content_value}