Python 找不到瓶子模板(错误500)
我计划制作文件管理器系统,但奇怪的是,当我应用返回目录内容的函数时,它会引发一个错误 这是我返回目录内容的函数(在我的机器上100%工作) 这里是来自文件管理器系统的代码Python 找不到瓶子模板(错误500),python,python-2.7,template-engine,bottle,Python,Python 2.7,Template Engine,Bottle,我计划制作文件管理器系统,但奇怪的是,当我应用返回目录内容的函数时,它会引发一个错误 这是我返回目录内容的函数(在我的机器上100%工作) 这里是来自文件管理器系统的代码 @route("/TofePanel/FileManager/<filepath:path>") def FileMamager(filepath): if request.get_cookie("__auth",secret="xxxxxxxx") is "xxxxxxxx": cont=
@route("/TofePanel/FileManager/<filepath:path>")
def FileMamager(filepath):
if request.get_cookie("__auth",secret="xxxxxxxx") is "xxxxxxxx":
cont=GET_Contents(filepath)#just calling the function and ignore result
return template("static/templates/TCP/FileMgr",PATH=filepath)
else:
redirect("/TofePanel/Login")
@route(“/TofePanel/FileManager/”)
def FileMaManager(文件路径):
如果request.get\u cookie(“\u auth”,secret=“xxxxxxxx”)是“xxxxxxxx”:
cont=GET_Contents(filepath)#只调用函数并忽略结果
返回模板(“static/templates/TCP/FileMgr”,PATH=filepath)
其他:
重定向(“/TofePanel/Login”)
它会引发一个错误,提示:Template'static/templates/TCP/FileMgr'未找到。
但是当我注释
cont=GET_Contents(filepath)#只需调用函数并忽略结果
就可以了 不要更改工作目录;模板加载逻辑依赖于当前工作目录保持稳定
无需更改工作目录,即可轻松列出目录:
def GET_Contents(filepath):
return os.listdir(os.path.join('files', filepath))
先生你太棒了
def GET_Contents(filepath):
return os.listdir(os.path.join('files', filepath))