图像不显示在cherrypy项目上
问题描述:
我无法获取图像以显示在我的cherrypy项目上。 我试过看着其他类似的问题发布在*上,但仍然无法让它工作。图像不显示在cherrypy项目上
我的代码:
class my_class():
def index(self):
html_script = '''<img src="resources/file.gif">'''
return(html_script)
index.exposed = True
cherrypy.config.update({'server.socket_host' : '0.0.0.0', 'server.socket_port': 8080, '/images': {'tools.staticdir.on': True, 'tools.staticdir.dir': '/home/user/cherrypy/site/resources'}})
cherrypy.quickstart(my_class())
文件不存在目录
感谢
答
你真的应该阅读更多关于HTTP的服务器的工作。您提供的网址为/home/user/cherrypy/site/resources
,其网址为/images
。
class my_class():
def index(self):
html_script = '''<img src="/images/file.gif">'''
return(html_script)
index.exposed = True
cherrypy.config.update({'server.socket_host' : '0.0.0.0',
'server.socket_port': 8080,
'/images': {
'tools.staticdir.on': True,
'tools.staticdir.dir': '/home/user/cherrypy/site/resources'}
})
cherrypy.quickstart(my_class())
如何提供静态文件? – Daniel 2014-11-05 18:43:07
我不明白你在问什么。 – Qui 2014-11-05 18:48:14