"""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)
Note: This post is out of date. If you'd like to run Python on your Android device, please see my Android Scripting Environment project. Here's an early Christmas present for all those Python fanatics (self included) out there! With a lot of help from my friends (thanks Manuel and Thomas !) I managed to install Python 2.4.5 on my G1. It's still rough around the edges, but I think it's a good start. Klaus Reimer has a nice overview of how to cross-compile Python . My instructions borrow a lot from his. Download and build the Android source . These directions assume that you have installed the source to /android_src . Download and build the Python 2.4.5 source . These directions assume that you have installed the source to /python_src . Make copies of python and pgen for use later in the build process then clean up. $ cd /python_src $ cp python hostpython $ cp Parser/pgen Parser/hostpgen $ make distclean Apply the following patch to the Python source. diff -r -c -b P...