Skip to content

Instantly share code, notes, and snippets.

@thevkozlovsky
Created July 2, 2014 18:09
Show Gist options
  • Save thevkozlovsky/fefe145cbaac8717cf59 to your computer and use it in GitHub Desktop.
Save thevkozlovsky/fefe145cbaac8717cf59 to your computer and use it in GitHub Desktop.
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 [file.read()]
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