python - No Such Resource 404 error -
i want run index.html. when type localhost:8080 index.html should executed in browser. giving no such resource. specifying entire path of index.html. please me out.??
from twisted.internet import reactor twisted.web.server import site twisted.web.static import file resource = file('/home/venky/python/twistedpython/index.html') factory = site(resource) reactor.listentcp(8000, factory) reactor.run()
this related difference between url ending slash , 1 without. appears twisted considers url @ top level (like http://localhost:8000
) include implicit trailing slash (http://localhost:8000/
). means url path includes empty segment. twisted looks in resource
child named ''
(empty string). make work, add name child:
from twisted.internet import reactor twisted.web.server import site twisted.web.static import file resource = file('/home/venky/python/twistedpython/index.html') resource.putchild('', resource) factory = site(resource) reactor.listentcp(8000, factory) reactor.run()
also, question has port 8080
code has 8000
.
Comments
Post a Comment