async def take_screenshot():
    """
    Takes a screenshot using pyautogui and returns it to the client.

    Returns:
        The screenshot image file
    """
    import pyautogui
    try:
        # Create a temporary directory if it doesn't exist
        temp_dir = os.path.join(tempfile.gettempdir(), "upsonic_screenshots")
        os.makedirs(temp_dir, exist_ok=True)

        # Generate a unique filename
        filename = f"screenshot_{uuid.uuid4()}.png"
        file_path = os.path.join(temp_dir, filename)

        # Take the screenshot
        screenshot = pyautogui.screenshot()
        screenshot.save(file_path)

        # Return the file and clean up after sending
        return FileResponse(
            file_path,
            media_type="image/png",
            filename=filename,
            background=asyncio.create_task(cleanup_screenshot(file_path))
        )
    except Exception as e:
        print(traceback.format_exc())
        raise HTTPException(status_code=500, detail=str(e))

    Takes a screenshot using pyautogui and returns it to the client.

    Returns:
        The screenshot image file
    
src/upsonic/server/others/server/server.py