Mercurial > hg > svgsitemap
comparison 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 |
comparison
equal
deleted
inserted
replaced
1:084088505eea | 2:30d03e830354 |
---|---|
3 from webob import Request, Response | 3 from webob import Request, Response |
4 | 4 |
5 def example(environ, start_response): | 5 def example(environ, start_response): |
6 link = '<a href="/%s">%s</a>' | 6 link = '<a href="/%s">%s</a>' |
7 body = '<br/>'.join([link % (i,i) for i in range(30)]) | 7 body = '<br/>'.join([link % (i,i) for i in range(30)]) |
8 body = '<html><body>%s</body></html>' % body | 8 body = '<html><body><a href="/map">map</a><br/>%s</body></html>' % body |
9 response = Response(content_type='text/html', body=body) | 9 response = Response(content_type='text/html', body=body) |
10 return response(environ, start_response) | 10 return response(environ, start_response) |
11 | 11 |
12 def factory(): | 12 def factory(): |
13 dirname = os.path.dirname(os.path.abspath(__file__)) | 13 dirname = os.path.dirname(os.path.abspath(__file__)) |
14 inifile = os.path.join(dirname, 'example.gv.txt') | 14 inifile = os.path.join(dirname, 'example.gv.txt') |
15 svgfile = os.path.join(dirname, 'example.svg') | 15 svgfile = os.path.join(dirname, 'example.svg') |
16 app = MapserverMiddleware(example, svgfile) | 16 app = MapserverMiddleware(example, svgfile) |
17 app = SVGSiteMap(app, file=inifile, output=svgfile) | 17 app = SVGSiteMap(app, file=inifile, output=svgfile, name='foo.com') |
18 return app | 18 return app |
19 | 19 |
20 if __name__ == '__main__': | 20 if __name__ == '__main__': |
21 from wsgiref import simple_server | 21 from wsgiref import simple_server |
22 server = simple_server.make_server(host='0.0.0.0', port=int(54321), app=factory()) | 22 server = simple_server.make_server(host='0.0.0.0', port=int(54321), app=factory()) |