Forums

Bottle templates path

Hi!

I have simple bottle app - http://yncoder.pythonanywhere.com/, with STE templates.

This code generate error "Template not found". This is obvious from Bottle doc.

@error(404)
def error404(error):
    return template( '404.tpl' )

I've try this code

@error(404)
def error404(error):
    return template( '/home/yncoder/infinity/404.tpl' )

It's working. But this is not good. This topic doesn't help.

Question is - how to configure paths to STE template outside the code?

The docs that you linked to suggest adding the absolute path to the bottle TEMPLATE_PATH. You could also change the working directory of your web app, since the bottle docs also say that templates are searched from the working directory.

I place tpl templates in working copy, where main.py placed. It's not help.

Did you set the TEMPLATE_PATH, as described in the Bottle docs or change the working directory of your web app?

Yes, now it's working fine.

I've modified /var/www/yncoder_pythonanywhere_com_wsgi.py bottle cfg

if project_home not in bottle.TEMPLATE_PATH:
    bottle.TEMPLATE_PATH.insert(0, project_home)

It's work, but it's not obvious. I think you can update doc for it.

glad you figured it out! will have a look at updating our docs, but hopefully in the meantime anyone that hits the same problem will find this thread.