我想设置我的http服务器的静态目录,并在其中放入一些图片,以便用户可以使用该网址获取我的图片。但是我失败了,下面的代码不起作用:
# 静态路径
STATIC_DIRNAME = "resources"
# 设置static path
settings = {
"static_path": os.path.join(os.path.dirname(__file__), STATIC_DIRNAME),
}
# and I passed settings to Application
app = tornado.web.Application([
(r"/pictures", handler.PicturesHandler),
], **settings)
如何将静态目录设置为“resources”?
(我希望通过网址获取我的图片,例如:localhost:8888/resources/1.jpg
)
答案 0 :(得分:4)
settings = {
"static_path": os.path.join(os.path.dirname(__file__), STATIC_DIRNAME),
"static_url_prefix": "/resources/",
}