#!/usr/bin/env python
from __future__ import with_statement

import os

from eventlet import api
from eventlet import greenio
from eventlet import wsgi
from pprint import pprint

from Urlencode import controllers
from Urlencode import views

static_types = { 
        'png' : 'image/png',
        'jpg' : 'image/jpeg',
        'jpeg': 'image/jpeg',
        'gif' : 'image/git',
        'css' : 'text/css',
        'js'  : 'text/javascript',
}

def app(environ, start_response):
    pprint(environ)
    path = environ['PATH_INFO']
    controller = controllers.get(path)

    if controller:
        klass, attr = controller
        controller = klass(start_response, **environ)
        controller.prepare()
        return getattr(klass, attr)(controller)

    ##
    ## If we don't have a static file, or somebody is giving me a crap URL
    ## I'm just going to bounce them back
    if '..' in path or not path.startswith('static') \
            or not os.path.exists(path):
        start_response('404 Not Found', [('Content-Type', 'text/plain')])
        return ['Not Found\r\n']

    start_response('404 Not Found', [('Content-Type', 'text/plain')])
    return ['Not Found\r\n']
    segments = path.split('.')
    if static_types.get(segments[-1]):
        start_response('200 OK', [('Content-Type', static_types[segments[-1]])])
    else:
        start_response('200 OK', [('Content-Type', 'text/plain')])
    fd = None
    try:
        fd = open(path, 'r')
        return fd.read()
    finally:
        if fd:
            fd.close()


@@ -713,16 +713,17 @@
  return 
+%5B
 getattr(
@@ -746,16 +746,26 @@
 troller)
+ + '%5Cr%5Cn'%5D
 %0A%0A    ##
@@ -926,16 +926,17 @@
 tswith('
+/
 static')
@@ -972,16 +972,30 @@
 .exists(
+os.getcwd() + 
 path):%0A 
@@ -1105,107 +1105,8 @@
 '%5D%0A%0A
-    start_response('404 Not Found', %5B('Content-Type', 'text/plain')%5D)%0A    return %5B'Not Found%5Cr%5Cn'%5D%0A
     
@@ -1370,16 +1370,30 @@
  = open(
+os.getcwd() + 
 path, 'r
@@ -1410,16 +1410,17 @@
  return 
+%5B
 fd.read(
@@ -1420,16 +1420,17 @@
 d.read()
+%5D
 %0A    fin

Enable run.py to serve static files, properly return a list