I'm trying to learn some Bottle basics and follow the tutorial on the bottlepy.org pages.
First I'll say: running on Ubuntu (12.04 I think?). I installed bottle via sudo easy_install bottle
which installed it only into my python2.7 dist-packages. I've read somewhere that bottle.py is intentionally dependency-less, and that copying bottle.py
into an available directory to get it to work in python3 (I'm trying to use python3.2) is reasonable.
MWE:
In helloworld.wsgi I have:
#!/usr/bin/python3
from bottle import debug, route, run, template, view
@route("/hello")
@route("/hello/<name>")
@view("base")
def hello(name=None):
return dict(name=name)
debug(True)
run(host="localhost", port=8080)
And in views/base.tpl I have:
<%
if name is not None:
name = name.title().strip()
else:
name = "World"
%>
<p>Hello {{name}}!</p>
But when I try to navigate to a site (either localhost:8080/hello or localhost:8080/hello/dude ) I'm getting an error:
SyntaxError: invalid syntax
referring to the '>' that closes the '%>' (line 6).
I'm not sure why I'm getting this error - I pretty much copied the examples from the website verbatim, and don't know how else to enclose python code blocks in template text (I don't think using % at the beginning of every code line is as reasonable a way to do it).
Any thoughts or ideas? Thanks