什么我想实现:Bottle.py MVC“找不到模板”。
下面是我试图运行的代码从\ MongoDB的\博客\ blog.py
@bottle.route('/')
def blog_index():
cookie = bottle.request.get_cookie("session")
username = sessions.get_username(cookie)
return bottle.template('blog_template',username=username))
从终端和浏览到本地主机上运行blog.py后: 8082我得到了以下错误:
Template 'blog_template' not found.
我上周类似的问题,我固定通过改变文件夹的权限为777(只是为了排除权限问题),但没有任何权限当前设置为上帝所有子文件夹\ mongodb和我仍然遇到同样的问题。
模板都位于\ MongoDB的\博客\意见bottle.py文档中指定
目前是文件夹的权限如下:(稳压器是我与登录的用户)
-rwxrwxrwx 1 regulator regulator 718 Mar 23 2015 blog_template.tpl
-rwxrwxrwx 1 regulator regulator 1211 Mar 23 2015 entry_template.tpl
-rwxrwxrwx 1 regulator regulator 113 Mar 23 2015 error_template.tpl
-rwxrwxrwx 1 regulator regulator 816 Mar 23 2015 login.tpl
-rwxrwxrwx 1 regulator regulator 581 Mar 23 2015 newpost_template.tpl
-rwxrwxrwx 1 regulator regulator 1454 Mar 23 2015 signup.tpl
-rwxrwxrwx 1 regulator regulator 368 Mar 23 2015 welcome.tpl
我敢肯定这是一个基于权限的问题,我已经忽略了一些非常基本的,但因为我一直在解决此为近3小时,我希望得到一些新鲜的眼光,给它看。
bottly.py需要什么权限才能工作?这是否记录在任何地方(我通过http://bottlepy.org/docs/看到无法找到此信息)?
--------------------编辑-------------------
由于写作这个我也试过以下
我已经重新创建一个新的测试项目来测试只有部分模板文件夹结构
测试 | _test.py | _views | __test.tpl
- 我有trie d将其作为SUDO运行,而不是sudo。
- 所有文件夹的权限是777
在test.py的代码如下
from bottle import route, run, template @route('/hello') def hello(): ##return "<h1>Hello World!</h1>" output = template('test') return output run(host='0.0.0.0', port=8080)
权限
[email protected]:/mongodb$ ls -l /mongodb/test/*
-rwxrwxrwx 1 root root 191 Jan 25 19:10 /mongodb/test/test.py
/mongodb/test/views:
total 4
-rwxrwxrwx 1 root root 141 Jan 25 19:12 test.tpl
,最后.tpl夹
<!DOCTYPE html>
<html>
<head>
<title>Why wont I work!!</title>
</head>
<body>
<h1>THIS IS A TEST</h1>
IF YOU CAN SEE THIS THE TEST WORKS!!!
</body>
</html>
感谢了,没遗憾的是未解决的问题! –
@WarrenGardner - 也许用一个小小的工作例子更新你的文章? –
那么上周工作的那个不行,所以我无法发布一个工作示例。我将在我的* shudders * Windows机器上安装bottle.py作为文件夹权限不应该是一个问题 –