현재 파이썬에서 bottle framework을 사용하여 간단한 웹 응용 프로그램을 작성하고 있습니다.파이썬 병 프레임 워크 오류 500 : 데몬 모드에서 템플릿을 찾을 수 없습니다.
#!/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 서버에서 데몬으로 실행하려면 :
구조
lib
- bottle.py
- bottledaemon.py
- lockfile.py
- __init__.py
view
- dashboard.tpl
run.py
그리고 여기 내 run.py 코드 : 여기에 내 응용 프로그램 구조입니다 bottle daemon script으로 전달합니다.
문제 코드 실행
작동 비 - daemonized. 올바른 템플릿을 보여 주며 CLI에서 HTTP 요청을 볼 수 있습니다.
그러나 대몬 모드에서 동일한 코드를 실행하면 데몬으로 시작되므로 제대로 작동하지만 더 이상 템플릿을 찾을 수 없습니다.
Error: 500 Internal Server Error
Sorry, the requested URL 'HERE IS MY WEBSITE URL' caused an error:
Template 'template' not found.
그래서는 .tpl 파일의 파일 경로처럼 보이는 내가 daemonized 모드에서 웹 서버를 시작할 때 더 이상 찾을 수 없습니다 : 그것은 나에게이 오류 MSG를 보여줍니다. 나는 이미 많은 것들을 시도했지만 그것을 이해할 수 없으며 경로를 동적으로 유지하고 싶습니다. 어떤 제안이 있니?
감사합니다.
역 추적 (마지막으로 가장 최근 통화) : 파일 "run.py", 라인 6, TEMPLATE_PATH.insert에서 (0, os.path.abspath (os.path.join (os.path.dirname (__ file_ _), "view"))) NameError : 'TEMPLATE_PATH'이름이 정의되어 있지 않습니다. –
상단 줄을 보시고, 가져 오기 목록에 추가해야합니다. – CasualDemon
Thanks mate! 이제 데몬이 다시 시작됩니다. 여전히 같은 500 오류 tho. 제공 한 코드에 삽입해야하는 고정 경로가 있습니까? –