import network, socket, time
from neopixel import NeoPixel
from machine import Pin

LED_GPIO = const(27)
matrix_size_x = const(5)
matrix_size_y = const(5)
is_atom_matrix = True

np = NeoPixel(Pin(LED_GPIO), matrix_size_x * matrix_size_y)

ssid=[SSID]
password=[PASSWORD]

def connect():
    wlan=network.WLAN(network.STA_IF)
    wlan.active(True)
    wlan.connect(ssid,password)
    while wlan.isconnected() == False:
        print('Waiting for connection...')
        time.sleep(1)
    ip=wlan.ifconfig()[0]
    print(f'Connected on {ip}')
    return ip

def open_socket(ip):
    address=(ip,80)
    connection=socket.socket()
    connection.bind(address)
    connection.listen(1)
    return connection

def get_html(html_name):
    with open(html_name, 'r') as file:
        html=file.read()
    return html

def serve(connection):
