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()
评论列表
文章目录