jd_web.py 文件源码

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

项目:jd-crawler 作者: qiaofei32 项目源码 文件源码
def GET(self, *args):
        dir, name = args[-2:]
        dir_path = 'templates/%s/' %dir
        ext = name.split(".")[-1]
        cType = {
            "css": "text/css",
            "png": "images/png",
            "jpg": "images/jpeg",
            "gif": "images/gif",
            "ico": "images/x-icon",
            "js" : "text/javascrip",
        }
        if name in os.listdir(dir_path):
            web.header("Content-Type", cType[ext])
            file_path = '%s/%s' %(dir_path, name)
            return open(file_path, "rb").read()
        else:
            raise web.notfound()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号