【发布时间】:2015-04-26 15:14:15
【问题描述】:
在开发服务器上运行,我可以在没有 CSS 的情况下渲染 0.0.0.0:8080/index.html,但不会加载静态文件。 0.0.0.0:8080/static 导致“未找到”并且 0.0.0.0:8080/static/style.css 得到 404。
我在 Google 上搜索到的所有引用或链接都指向了 http://webpy.org/cookbook/staticfiles,我觉得我已经遵循了这一点。
文件树
code.py
/web
...
/static
style.css
/images
...
/pages
index.html
code.py
import web
render = web.template.render('/home/keith/code/webpy/skeleton/pages/')
urls = (
'/', 'index',)
class index:
def GET(self):
return render.index()
if __name__ == "__main__":
app = web.application(urls, globals())
app.run()
/pages/index.html
...
<link rel="stylesheet" type="text/css" href="static/style.css" />
...
不胜感激!
【问题讨论】: