GET method not getting executed

46 views
Skip to first unread message

rahul pathak

unread,
Oct 18, 2015, 1:24:01 AM10/18/15
to web.py
Hi,

I started with python web module and i have no experience with web.

I used the example which is on the web.py site -

----------------------------------
import web

urls = {
        '/', 'index'
}

class index:
        def GET(self):
                return "Hello World"

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

But when I execute this code on terminal and put http://localhost:8080/ in browser then I get  "not found"  in browser and at terminal I get error -

$ python webse.py
127.0.0.1:51204 - - [18/Oct/2015 10:29:46] "HTTP/1.1 GET /" - 404 Not Found
127.0.0.1:51204 - - [18/Oct/2015 10:29:47] "HTTP/1.1 GET /" - 404 Not Found
127.0.0.1:51204 - - [18/Oct/2015 10:29:47] "HTTP/1.1 GET /" - 404 Not Found

Looks like GET method is not visible and not getting executed.

Anand Chitipothu

unread,
Oct 18, 2015, 1:27:47 AM10/18/15
to webpy
There is an issue with your URLs. You've used curly brackets {} instead of parenthesis () for enclosing urls. That makes them a set and set is unordered. I think the order of them got changed. 

    >>> urls = {
    ...         '/', 'index'
    ... }
    >>> print urls
    set(['index', '/'])

enclosing the urls in parenthesis will solve the issue.

Anand

rahul pathak

unread,
Oct 18, 2015, 1:46:09 AM10/18/15
to web.py
ok, understood. Its working now. Thanks
Reply all
Reply to author
Forward
0 new messages