Python Bottle 500 frame error: cannot find template in Daemon mode

I am currently working on a simple webapp in Python using bottle frames . Here is my application structure:

Structure

lib
    - bottle.py
    - bottledaemon.py
    - lockfile.py
    - __init__.py
view
    - dashboard.tpl
run.py

And here is my run.py code:

#!/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()

So, I want the WSGI server to start in the daemon, passing it to the sample bottle script .

Problem

When you run the code, not demonized, it works. It shows me the correct template, and in the CLI I see HTTP requests.

However, when I run the same code in demonized mode, it runs as a daemon, so it works fine, but it can no longer find the template. This shows me this msg error:

Error: 500 Internal server error

, URL- ", --URL" :

"" .

, , .tpl , - . , , . ?

!

+4
1

, , , TEMPLATE_PATH .

from bottle import route, template, run, debug, request, static_file, TEMPLATE_PATH
from bottledaemon import daemon_run

import os

TEMPLATE_PATH.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "view")))

# rest of script

Edit:

, , , . bottledaemon daemon DaemonContext, '/' bottledaemon , . , view, "/view" .

+6

All Articles