python - Trouble with Tornado and JavaScript Libraries -
i'm trying write simple python web application using tornado web server , having trouble using javascript libraries need. wanted use protovis javascript plotting library, added following 'hello world' code snippet template.html:
<script type="text/javascript" src="/protovis-d3.2.js"></script> <script type="text/javascript+protovis"> new pv.panel() .width(150) .height(150) .anchor("center") .add(pv.label) .text("hello, world!") .root.render(); </script>
whenever run webserver, however, , try accessing page, following error @ console:
warning:root:404 /protovis-d3.2.js (127.0.0.1) 0.46ms
the protovis.js file in same directory server.py file, , permissions set correctly. same error when trying src , javascript file know there isn't problem protovis.js file, tornado server's routing.
does know how can src javascript code, thanks.
you should read documentation static files.
in particular, standard way to:
create 'static' directory in root of application
add following application settings:
"static_path": os.path.join(os.path.dirname(file), "static")
put protovis-d3.2.js in static directory
- refer file /static/protovis-d2.2.js in html
Comments
Post a Comment