virtualenv
virtualenv is a tool to create isolated Python environments.
Install from source
- su
- cd /tmp
curl -O https://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.10.1.tar.gz
- tar xvfz virtualenv-1.10.1.tar.gz
- cd virtualenv-1.10.1
- python setup.py install
Setup virtualenv with python3 in Debian
jinja2test.py
1 import sys
2 sys.stdout = sys.stderr
3 import cherrypy
4
5 from jinja2 import Environment, FileSystemLoader
6 env = Environment(loader=FileSystemLoader('/home/vitor/tmp/projectx/templates'))
7
8 cherrypy.config.update({'environment': 'embedded'})
9
10 class Jinja2Test(object):
11 @cherrypy.expose
12 def index(self):
13 return "Hello World Jinja2Test!!!!"
14 @cherrypy.expose
15 def add(self,param1,param2):
16 return str( int(param1)+int(param2) )
17 @cherrypy.expose
18 def testpage(self):
19 t = env.get_template('test.html')
20 navItems=[]
21 for i in range(1,10):
22 navItems.append( {'href':'hrefx','caption':'cap %d'%(i) } )
23 return t.render( titlex="Titleeeee" , navigation=navItems )
24
25 jjtest = Jinja2Test()
26 cherrypy.server.socket_host = '0.0.0.0'
27 cherrypy.quickstart(jjtest)