pygame, pywebsite -- a website with joystick controls???!??!

Here's a song program written with a pygame style api:

import pygame

counts = {}
going = True

while going:

events = pygame.event.get()

for e in events:
if e.type == HTTP:

if e.path.startswith('/song/'):
song_id = e.path[6:]

if e.method == "POST":
counts[song_id] = counts.get(song_id, 0) + 1


elif e.path == "/":
if e.method == "GET":
data = ','.join(['%s=%s' % (k, v) for k, v in counts.iteritems()])

elif e.method == "DELETE":

going = False

Note this is not in pygame yet, but is just the possible API. So it can't be benchmarked since it doesn't really exist. It's Vapour-ware ™, so only good for making clouds -- not websites.

Compared to the others*1 it has:
  • less code (measured in LOC, or # of characters)
  • simpler code (no need to write functions or classes).
  • JOYSTICK control

  • Note: this is a response to this series of posts about a basic REST application written in python.

    Starting with "Eric Florenzano's deliberately minimalist WSGI application illustrating a bare metal WSGI application with RESTful behaviour has drawn out from other Python web application framework communities a number of useful comparisons"

    1. Christian Wyglendowski's entry using cherrypy
    2. Tim Parkin's restish approach
    3. Grok showing real object persistence by Martijn Faasen.
    4. A Werkzeug solution also by Tim Parkin.
    5. Carlos de la Guardia provides a solution via repoze.bfg, which, like Grok, shows how Zope3 technologies can be used.
    6. Then mike Watkins does the same thing with qp
    7. this post (self post) where we add Joystick control to a Vapour-ware ™ REST framework.


    Michael Watkins said…
    I think you are on to something... forget REST, all web sites should be Joystick-accessible!
    Marius Gedminas said…
    Nice, but I cannot help noticing that your indentation levels are a bit messed up. The "elif e.path == '/':" bit should be aligned with "if e.path.startswith('/song'):", and not with "if e.type == HTTP".
    illume said…
    Indeed! The indentation was very broken. Thanks.

    Popular posts from this blog

    Is PostgreSQL good enough?

    pygame on pypy usable

    Experiments with new low latency PyPy garbage collector in a thread.