11 lines
349 B
Python
11 lines
349 B
Python
from fastapi import APIRouter, status
|
|
from typing import Dict
|
|
import random
|
|
|
|
router = APIRouter()
|
|
|
|
@router.get("/randomcolour", status_code=status.HTTP_200_OK, response_model=Dict[str, str])
|
|
async def get_random_colour():
|
|
"""Generate a random hex colour"""
|
|
random_hex = f"#{random.randint(0, 0xFFFFFF):06x}"
|
|
return {"colour": random_hex} |