main.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:professional-services 作者: GoogleCloudPlatform 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号