什麼我想實現: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作爲文件夾權限不應該是一個問題 –