WiFi IP in Uno Q problem

The AppLab has limited material to work with.
I have used AI to generate Python code with web interface to control simple motor with sketch..

The output keeps telling me to login to ip address that is different than the one I ping.

The code seems stuck on using some ip address and I am not sure what to do.

I can ping correct address but the output seems to hold onto some original ip I first connected.

Any thoughts.

@sbussom, welcome to the forum.

What steps have you taken to research and build your web interface on the UNO Q? Have you used any bricks in the project? How did you verify that the generated code is appropriate to the task you require it to do?

What is the address? Is it something local on your network? Or is it something else that the AI might have included in the generated code?

You might start by reading this:

How to get the best out of this forum

Please take careful note of the sections about AI generated code.

Thanks. Here is the Python Code, i have a seperate file requirements.txt that simply says flask in it.
None of the bricks create wifi controller of a motor.
Seeing the AppLab and Uno Q are newer it is hard to find specific information..Maybe I just use bluetooth but not sure how to get the code for that. This is my first robotics project. Thanks.

<
from arduino.app_utils import *
import socket
from flask import Flask, render_template_string
from threading import Thread

app = Flask(name)

Get the board's WiFi IP address and print it

def get_ip():
try:
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("8.8.8.8", 80))
ip = s.getsockname()[0]
s.close()
return ip
except Exception:
return "unable to detect - use ping/SSH IP"

ip = get_ip()
print("=== MOTOR CONTROL APP STARTED ===")
print(f"WiFi IP Address: {ip}")
print(f"Open http://{ip} in your browser to control the motors!")
print("Web server (Flask) starting on port 80...")

Embedded HTML control page

HTML = """

UNO Q Motor Control body { text-align: center; font-family: Arial, sans-serif; background: #f0f0f0; padding: 20px; } h1 { color: #333; } button { font-size: 24px; padding: 20px; margin: 10px; width: 200px; border: none; border-radius: 10px; cursor: pointer; } .stop { background: red; color: white; } .go { background: #4CAF50; color: white; }

Arduino UNO Q
L298N Motor Control

Forward
Backward
Turn Left Turn Right
STOP

Home """

@app.route("/")
def index():
return render_template_string(HTML)

@app.route("/forward")
def forward():
Bridge.call("setMotors", 300, 300)
return "

Going Forward

Back to controls"

@app.route("/backward")
def backward():
Bridge.call("setMotors", -300, -300)
return "

Going Backward

Back to controls"

@app.route("/left")
def left():
Bridge.call("setMotors", -250, 250)
return "

Turning Left

Back to controls"

@app.route("/right")
def right():
Bridge.call("setMotors", 250, -250)
return "

Turning Right

Back to controls"

@app.route("/stop")
def stop():
Bridge.call("setMotors", 0, 0)
return "

Stopped

Back to controls"

Run Flask server in a background thread

def run_server():
app.run(host="0.0.0.0", port=80, debug=False, use_reloader=False)

server_thread = Thread(target=run_server)
server_thread.daemon = True
server_thread.start()

Keep the app running

def user_loop():
pass

App.run(user_loop=user_loop)

/>

I was able to figure it out. I added the Brick WebUI and then had AI rewrite code instead with Streamlit web interface to control and it generated IP address that worked and had my robot wheels spinning!