import urllib.request
import re
from http.cookiejar import CookieJar

cj = CookieJar()
opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
opener.open('http://localhost:8069/web/login?db=dine360_restaurant_antalya')

try:
    resp = opener.open('http://localhost:8069/reservation')
    html = resp.read().decode('utf-8')
    print('STATUS:', resp.status)
    print('HTML length:', len(html))
    
    # Check if CSS variables exist in the HTML (which means QWeb loaded them from website)
    contains_variables = '--res-primary-color:' in html and '--res-secondary-color:' in html
    print('HTML contains custom theme CSS variables:', contains_variables)
    
    # Print the style blocks found in HTML
    style_blocks = re.findall(r'<style>.*?</style>', html, re.DOTALL)
    for block in style_blocks:
        if '--res-primary-color' in block:
            print('Found custom :root variables style block:')
            print(block)
except Exception as e:
    print('ERROR:', e)
