def get(self, path):
"""Serve the requested resource to the client.
Super class will validate credentials. Returns the file in the HTTP
response, or a 404 if the resource can not be found.
Args:
path: path to the resource.
"""
abs_path = os.path.abspath(os.path.join('static', path))
if '..' in abs_path:
self.response.set_status(400)
return
if os.path.isdir(abs_path) or abs_path.find(os.getcwd()) != 0:
self.response.set_status(403)
return
try:
with open(abs_path, 'r') as f:
content_type = mimetypes.guess_type(abs_path)[0]
self.response.content_type = content_type
self.response.out.write(f.read())
except IOError:
self.response.set_status(404)
评论列表
文章目录