"""Record and display shout outs for the life of the server."""
import gsd
TEMPLATE = """
<html>
<head>
<title>Shout Outs!</title>
</head>
<body>
<form action="/" method="get">
<input name="shout">
<input type="submit" value="Shout!">
</form>
<?
for shout in self.shout_outs:
print shout, '<br>'
?>
</body>
</html>
"""
class ShoutOuts(gsd.App):
"""A simple GSD app that records shout outs for the life of the server."""
def __init__(self):
self.shout_outs = []
def GET_(self, shout=None):
"""Display shout outs and form to add new ones."""
if shout is not None:
self.shout_outs.append(shout[0])
self.Render(TEMPLATE, locals())
def GET_reset(self):
"""Reset the list of shoutouts."""
self.shout_outs = []
self.Redirect('/')
if __name__ == '__main__':
app = ShoutOuts()
print 'http://localhost:8000/'
app.Serve('localhost', 8000)
I just published Bot Commander , the code for my Lego NXT rover . There's a lot left to be done, but release early and often, right? Currently it provides a UI for controlling the direction and speed of all three motor ports on the NXT brick. You can link motors together to adjust their speed in unison. In addition, you can enable "Tilt Control" for a steering-wheel-type experience. To use tilt control: Hook up motor A and B to be the left and right wheels of your vehicle. Hold the phone sideways (i.e. landscape). Tilt the phone forward and backward to drive forward and backward. Turn the phone right and left (like a steering wheel) to steer right and left. As you tilt the phone, you'll see the UI update the slider controls for the speed of motors A and B. I plan to expand the UI to provide a lot more than just motor control. Before that, though, I'll push a JAR to make it easy to integrate control of Lego NXT robots into your own Android project. The code