annotate example/example.py @ 2:30d03e830354

compute line widths
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 28 Dec 2010 16:47:36 -0800
parents 084088505eea
children aa4eab6dc994
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
084088505eea almost working
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
1 import os
0
7a60bacc6a22 initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2 from svgsitemap import *
7a60bacc6a22 initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3 from webob import Request, Response
7a60bacc6a22 initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4
7a60bacc6a22 initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5 def example(environ, start_response):
7a60bacc6a22 initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6 link = '<a href="/%s">%s</a>'
7a60bacc6a22 initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7 body = '<br/>'.join([link % (i,i) for i in range(30)])
2
30d03e830354 compute line widths
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
8 body = '<html><body><a href="/map">map</a><br/>%s</body></html>' % body
1
084088505eea almost working
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
9 response = Response(content_type='text/html', body=body)
0
7a60bacc6a22 initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10 return response(environ, start_response)
7a60bacc6a22 initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11
7a60bacc6a22 initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
12 def factory():
1
084088505eea almost working
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
13 dirname = os.path.dirname(os.path.abspath(__file__))
084088505eea almost working
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
14 inifile = os.path.join(dirname, 'example.gv.txt')
084088505eea almost working
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
15 svgfile = os.path.join(dirname, 'example.svg')
084088505eea almost working
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
16 app = MapserverMiddleware(example, svgfile)
2
30d03e830354 compute line widths
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
17 app = SVGSiteMap(app, file=inifile, output=svgfile, name='foo.com')
1
084088505eea almost working
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
18 return app
0
7a60bacc6a22 initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
19
7a60bacc6a22 initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
20 if __name__ == '__main__':
7a60bacc6a22 initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
21 from wsgiref import simple_server
1
084088505eea almost working
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
22 server = simple_server.make_server(host='0.0.0.0', port=int(54321), app=factory())
0
7a60bacc6a22 initial commit
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
23 server.serve_forever()