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
from pymongo import MongoClient
from gridfs import GridFS
from gridfs.errors import NoFile
#from bson import ObjectId
import sys
db = MongoClient(max_pool_size=15).example
fs = GridFS(db)
def application(environ, start_response):
path = filename='.' + environ['PATH_INFO']
file = fs.get_last_version(filename=path);
except NoFile:
start_response('404 Not Found', [('Content-Type', 'text/plain')])
return [b'Not Found']
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