By default template path is set to ./ or ./views/ in bottle.py, however this will not work and the following error message appear always in Windows environment.
Error: 500 Internal Server Error
Sorry, the requested URL 'http://localhost:8080/' caused an error:
Template 'hello_world' not found.
To overwrite a template path “template_lookup” should be used under return bottle.template function as shown below:
template_lookup=['C:/Python34/Lib/site-packages/views']
*Make sure that forward slash used instead of backslash.
The following sample code illustrates this:
***********************************************Python Code
***********************************************
import bottle
@bottle.route('/')
def home_page():
mythings = ['apple','orange','banana','peach']
return bottle.template('hello_world', username="Uma", things=mythings
, template_lookup=['C:/Python34/Lib/site-packages/views'])
bottle.debug(True)
bottle.run(host='localhost', port=8080)
Template "hello_world.tpl"
**********************************************
<!DOCTYPE html>
<html>
<head>
<title>Hello World!</title>
</head>
<body>
<p>
Welcome {{username}}
<p>
<ul>
%for thing in things:
<li>{{thing}}</li>
%end
</ul>
</body>
</html>