Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/357.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在龙卷风中设置静态路径?_Python_Python 3.x_Tornado - Fatal编程技术网

Python 如何在龙卷风中设置静态路径?

Python 如何在龙卷风中设置静态路径?,python,python-3.x,tornado,Python,Python 3.x,Tornado,我想设置http服务器的静态目录,并在其中放置一些图片,以便用户可以使用url获取我的图片。但我失败了,下面的代码不起作用: # 静态路径 STATIC_DIRNAME = "resources" # 设置static path settings = { "static_path": os.path.join(os.path.dirname(__file__), STATIC_DIRNAME), } # and I passed settings to Application app

我想设置http服务器的静态目录,并在其中放置一些图片,以便用户可以使用url获取我的图片。但我失败了,下面的代码不起作用:

# 静态路径
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)
如何将静态目录设置为“资源”

(我想通过url获取图片,例如:
localhost:8888/resources/1.jpg

使用


解决了我的问题!非常感谢。您能告诉我为什么吗?@ErumHuang请查看您可以通过发送静态路径设置作为关键字参数来提供静态文件的文档。我们将从/static/URI(可通过static\u url\u前缀设置配置)提供这些文件,并从同一目录提供/favicon.ico和/robots.txt。
settings = {
    "static_path": os.path.join(os.path.dirname(__file__), STATIC_DIRNAME),
    "static_url_prefix": "/resources/",
}