user-manual-de.md
print("Connected to WiFi. IP
# Initialize the robot
alvik = ArduinoAlvik()
alvik.begin()
sleep_ms(5000)
# HTML for the web interface
html =
"""
<!DOCTYPE html>
<html>
<head>
<title>Alvik Robot Control</title>
</head>
<body>
<h1>Control Alvik Robot</h1>
<form action="/up">
<button type="submit">Up</button>
</form>
<form action="/down">
<button type="submit">Down</button>
</form>
<form action="/left">
<button type="submit">Left</button>
</form>
<form action="/right">
<button type="submit">Right</button>
</form>
</body>
</html>
"""
# Specify a port
port =
8080
addr = socket.getaddrinfo('0.0.0.0', port)[0][-1]
s = socket.socket()
s.bind(addr)
s.listen(5)
s.settimeout(5)
print(f'Listening on
# Function to handle incoming HTTP requests
def
handle_request(conn):
try:
request = conn.recv(1024).decode('utf-8')
first_line = request.split('\n')[0]
path =
# Strip query strings (e.g., "/up?")
if
'?'
path = path.split('?')[0]
print(f"Request path:
address:", sta_if.ifconfig()[0])
{sta_if.ifconfig()[0]}:{port}')
first_line.split('
in
path:
{path}")
# Get the first line of the request
')[1]
# Extract the path (e.g., "/up")
49 / 70
2024-11-14