Tried every way but still unable to open the sample app with browser

32 views
Skip to first unread message

Yinuo Hong

unread,
Nov 3, 2017, 2:28:09 AM11/3/17
to web.py
I copied the sample program from http://webpy.org:
=====main.py=====
import web
urls=('/','Handle',)
class Handle:
    def GET(self):
        return 'hello!'
if __name__=="__main__":
    app=web.application(urls, globals())
    app.run()
================
Then type:# python main.py 1234
And netstat returns:  tcp        0      0 0.0.0.0:1234            0.0.0.0:*               LISTEN      10143/python

However, "http://public_ip:1234" is not reachable, and returns ERR_CONNECTION_TIMED_OUT

The Firewall service have been turned off.
Change to other ports doesn't help.
I don't know how can I work on it for the next step... anyone can help?

Jeff Silverman

unread,
Nov 3, 2017, 8:12:45 PM11/3/17
to we...@googlegroups.com
I tried it.  On the client side:

jeffs@jeffs-desktop:~/python (hints_dev)* $ curl localhost:1234
hello!jeffs@jeffs-desktop:~/python (hints_dev)* $ curl 192.168.0.16:1234
hello!jeffs@jeffs-desktop:~/python (hints_dev)* $ curl -6 http://[2602:61:7e5c:3b00:e52d:317e:9f1:2300]:1234
curl: (7) Failed to connect to 2602:61:7e5c:3b00:e52d:317e:9f1:2300 port 1234: Connection refused
jeffs@jeffs-desktop:~/python (hints_dev)* $ 
So it works under IPv4 and does not work under IPv6.  What does it look like on the server side?

jeffs@jeffs-desktop:~/python (hints_dev)* $ python webpy_demo.py 1234
127.0.0.1:38548 - - [03/Nov/2017 17:03:25] "HTTP/1.1 GET /" - 200 OK
127.0.0.1:38590 - - [03/Nov/2017 17:06:41] "HTTP/1.1 GET /" - 200 OK
192.168.0.16:39062 - - [03/Nov/2017 17:06:52] "HTTP/1.1 GET /" - 200 OK
127.0.0.1:38624 - - [03/Nov/2017 17:07:58] "HTTP/1.1 GET /" - 200 OK
192.168.0.16:39094 - - [03/Nov/2017 17:08:04] "HTTP/1.1 GET /" - 200 OK

I suspect the problem is that you are using public_ip as the IPv4 address.  Try using 127.0.0.1.  That should work.

That it doesn't work under IPv6 is not unexpected and could probably be fixed easily.


Best,

Jeff



--
You received this message because you are subscribed to the Google Groups "web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webpy+unsubscribe@googlegroups.com.
To post to this group, send email to we...@googlegroups.com.
Visit this group at https://groups.google.com/group/webpy.
For more options, visit https://groups.google.com/d/optout.



--
Jeff Silverman, linux sysadmin
nine two four   twentieth avenue east
Seattle, WA, nine eight one one two -3507
(253) 459-2318
jeffs...@gmail.c0m (note the zero!)
http://www.commercialventvac.com
See my portfolio of writings and talks

Yinuo Hong

unread,
Nov 6, 2017, 7:06:54 AM11/6/17
to web.py
Thank you Jeff!!! That really helped a lot!

在 2017年11月4日星期六 UTC+8上午8:12:45,Jeff Silverman写道:
To unsubscribe from this group and stop receiving emails from it, send an email to webpy+un...@googlegroups.com.

To post to this group, send email to we...@googlegroups.com.
Visit this group at https://groups.google.com/group/webpy.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages