def index(self, name=None, content=None):
"""Grab a file from gridfs, set the appropriate content-type header
and dump it to circuits.web for the rest.
"""
# Incorrect/incomplete data, redirect to /
if name is None or content is None:
return self.redirect("/")
# Set Content-Type header
self.response.headers["Content-Type"] = contentmap[content]
# Get the file, redirect to / if it doesnt exist
data = self.env.db.filenames.find_one({"name": name})
if not data:
return self.redirect("/")
f = self.env.gridfs.get(data["id"])
# Dump it
return f.read()