Mercurial > hg > svgsitemap
annotate example/example.py @ 15:61038b4e7425
initial version with acceptable formatting
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sun, 02 Jan 2011 13:55:49 -0800 |
parents | aa4eab6dc994 |
children | 1b077cb84be5 |
rev | line source |
---|---|
1 | 1 import os |
0 | 2 from svgsitemap import * |
3 from webob import Request, Response | |
4 | |
5 def example(environ, start_response): | |
6 link = '<a href="/%s">%s</a>' | |
7 body = '<br/>'.join([link % (i,i) for i in range(30)]) | |
2 | 8 body = '<html><body><a href="/map">map</a><br/>%s</body></html>' % body |
1 | 9 response = Response(content_type='text/html', body=body) |
0 | 10 return response(environ, start_response) |
11 | |
12 def factory(): | |
1 | 13 dirname = os.path.dirname(os.path.abspath(__file__)) |
14 inifile = os.path.join(dirname, 'example.gv.txt') | |
15 svgfile = os.path.join(dirname, 'example.svg') | |
16 app = MapserverMiddleware(example, svgfile) | |
9
aa4eab6dc994
* dont set node width, height; * move save() to its own function
Jeff Hammel <jhammel@mozilla.com>
parents:
2
diff
changeset
|
17 app = SVGSiteMap(app, file=inifile, output=svgfile) |
1 | 18 return app |
0 | 19 |
20 if __name__ == '__main__': | |
21 from wsgiref import simple_server | |
1 | 22 server = simple_server.make_server(host='0.0.0.0', port=int(54321), app=factory()) |
0 | 23 server.serve_forever() |