Skip to content

Instantly share code, notes, and snippets.

Embed
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 [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
You can’t perform that action at this time.