python - web.py doesn't find file -
i try create little website using web.py , webpysocketio, , have problem: web.py doesn't seem find file besides index.html.
here's webpy app:
import web socketio import socketioserver gevent import monkey monkey.patch_all() webpy_socketio import * urls = ( '/', 'index', ) urls += socketio_urls app = web.application(urls, globals()) socketio_host = "" socketio_port = 8080 application = app.wsgifunc() if __name__ == "__main__": socketioserver((socketio_host, socketio_port), application, resource="socket.io").serve_forever() class index: def get(self): render = web.template.render('templates/') return render.index() @on_message(channel="my channel") def message(request, socket, context, message): socket.send_and_broadcast_channel(message)
in template folder have index.html
(and socketio_scripts.html
):
<html> <head> <meta charset="utf-8"> <title>webpysocketio test</title> <object type="text/html" data="socketio_scripts.html"> <script> var socket = new io.socket(); socket.connect(); socket.on('connect', function() { socket.subscribe('my channel'); socket.send('asdf'); }); </script> </object> </head> <body> <div> </div> </body> </html>
now when run webiste, after visit in browser, following on terminal:
ip - - [date] "get /socketio_scripts.html http/1.1" 404 135 0.004273
why not find other html file?
i suspect /socketio_scripts.html
not correct url
file - seems odd that file @ root of document tree.
according several pages, should in .../templates/
. doubt ever accessed get
have @ the web.py tutorial. 1 big difference code pages have listed in urls
dispatch table:
urls = ( '/', 'hello', '/bye', 'bye')
Comments
Post a Comment