Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
from gevent import monkey; monkey.patch_all()
from gevent.pywsgi import WSGIServer
import os.path
upload_dir = '/home/uploads/'
def application(environ, start_response):
path = environ['PATH_INFO']
if not os.path.isfile(upload_dir + path):
start_response("404 Not Found", [('Content-type', 'text/plain')])
return [b'Not Found']
file = open(upload_dir + path)
start_response('200 OK', [('Content-Type', 'image/jpeg')])
return []
if __name__ == '__main__':
WSGIServer(('', 8080), application, log=None).serve_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment