python web_page fuction returns invalid syntax

I am writing a simple webserver on a esp32 to control some leds.

def web_page(color_hex, brightness):
html = """
<!DOCTYPE html>
<html>
<head>
    <title>LED Control</title>
    <script>
    function updateColor(color) {
        var xhr = new XMLHttpRequest();
        xhr.open("POST", "/color", true);
        xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        xhr.send('color=' + encodeURIComponent(color));
    }

    function updateBrightness(brightness) {
        var xhr = new XMLHttpRequest();
        xhr.open("POST", "/brightness", true);
        xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        xhr.send('brightness=' + encodeURIComponent(brightness));
    }
    </script>
</head>
<body>
    <h1>LED Control</h1>
    <input type="color" onchange="updateColor(this.value)">
    <input type="range" min="0" max="255" step="1" onchange="updateBrightness(this.value)">
</body>
</html>
"""
    return html

this is the function in micropython and it return a invalid syntax on return html. And i can’t find the problem.

as soon as i delete the part between script, it works again (doesn’t return a error). also the old funtion worked fine:

def web_page(color_hex, brightness):
    html = f"""<!DOCTYPE html>
<html>
<head><title>LED Control</title></head>
<body>
    <h1>LED Control</h1>
    <form action="/color" method="post">
        <input type="color" name="color" value="{color_hex}">
        <input type="submit" value="Set Color">
    </form>
    <br>
    <form action="/brightness" method="post">
        <input type="range" name="brightness" min="0" max="255" step="1" value="{brightness}">
        <input type="submit" value="Set Brightness">
    </form>
</body>
</html>"""
    return html

i am also not the brightest in java, so it might be really obvious.