Created
July 2, 2014 18:09
-
-
Save thevkozlovsky/fefe145cbaac8717cf59 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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