pythonweb.py

Accessing web.py web server


I'm trying to run the tutorial code for web.py, and everything works fine except when I try to access the web server using a browser it says it can't connect to the server. Here is the code:

import web

urls = (
    '/', 'index'
)

class index:
    def GET(self):
        return "Hello, world!"

if __name__ == "__main__":
    app = web.application(urls, globals())
    app.run()

I run it like this:

$ python code.py
http://0.0.0.0:8080/

As far as I can tell, this is exactly what the tutorial says to do, but like I say when I try to access the web server it gives me an error. For example, when I copy the address into firefox it gives me this error:

Firefox can’t establish a connection to the server at 0.0.0.0:8080.

Any ideas of what I've done wrong?


Solution

  • You can goto:

    http://localhost:8080 in your web-browser!

    Simply 0.0.0.0 means open to all incoming 'host's' whereas, you want to connect to your localhost