【发布时间】:2014-12-25 03:56:24
【问题描述】:
我目前正在使用bottle framework 在 Python 中开发一个简单的 web 应用程序。这是我的应用结构:
结构
lib
- bottle.py
- bottledaemon.py
- lockfile.py
- __init__.py
view
- dashboard.tpl
run.py
这是我的 run.py 代码:
#!/usr/bin/env python
from lib.bottle import route, template, run, debug, request, static_file
from lib.bottledaemon import daemon_run
debug(mode=True)
@route('/')
def show_index():
return template('dashboard')
# If the following line is enabled, the server will start in non-Daemon mode.
#run(host='0.0.0.0', port=80, debug=True)
# If the following lines are enabled, the server will start in Daemon mode.
if __name__ == "__main__":
daemon_run()
所以我希望 WSGI 服务器通过将其传递给bottle daemon script 来在守护程序中运行。
问题
当运行非守护程序的代码时,它可以工作。它显示了正确的模板,并且在 CLI 中我可以看到 HTTP 请求。
但是,当我在守护程序模式下运行相同的代码时,它确实作为守护程序启动,因此工作正常,但它再也找不到模板了。它向我显示了这个错误消息:
错误:500 内部服务器错误
抱歉,请求的 URL 'HERE IS MY WEBSITE URL' 导致错误:
找不到模板“模板”。
因此,当我以守护程序模式启动网络服务器时,似乎无法再找到 .tpl 文件的文件路径。我已经尝试了很多东西,但我想不通,我想保持路径动态。有什么建议吗?
谢谢!
【问题讨论】: