A web application can give a robot a browser-based control surface over a wired or Wi-Fi network. It lets a desktop or mobile operator send commands and view robot-provided information. section 6.0 section 6.1
Build the server in Python with Tornado: route a URL to a RequestHandler, listen on a port, and run the IOLoop. A handler can answer an HTTP GET request with JSON, or render an HTML template for the browser. section 5.5.1 section 6.3.1
Time service and page
Start with a handler that reads the robot server time. One version writes a timestamp dictionary as JSON; another renders basic.html with the timestamp, using a template directory and optional debug logging. Test the running service with curl. section 5.5.1 section 6.3.1
Listing 5.3 datews.py: Creating web service to report time on the robot server
#!/usr/bin/env python3
from datetime import datetime
from tornado.ioloop import IOLoop
from tornado.web import RequestHandler, Application
class MainHandler(RequestHandler):
def get(self):
stamp = datetime.now().isoformat()
self.write(dict(stamp=stamp))
app = Application([('/', MainHandler)])
app.listen(8888)
IOLoop.current().start()
This complete Python service maps the root path to a GET handler, returns the current timestamp as JSON, listens on port 8888, and starts Tornado's event loop. section 5.5.1
Expand a control application incrementally:
- Provide forward, backward, left, right, and spin actions, plus a no-operation action for browser-based network-performance measurement. section 6.4
- Design large, spaced movement buttons that work with desktop mice and mobile touch screens without scrolling. section 6.4.2
- Combine selectable snack buttons, a live camera stream, and robot actions that drive, push an item, and return to the start. section 11.4 section 11.5
Debug mode can be selected through the ROBO_DEBUG environment variable, enabling automatic reloading and generated error pages during development. Enhanced logging supports finding web-request failures. section 6.3.1 section 6.0







