玩webpy记
本人从来没有接触过web编程,突然对这个产生了兴趣。本人之前学过一些Python语言,有点基础。看到网上有很多关于Python的网络开发的资料,于是想玩一玩。
我所了解的Python网络开发框架有django, webpy。由于本人在web上没有什么基础,于是决定从轻量级的webpy入手。
我这里下载了一个webpy的源码。解压源码包,发现里面有个setup.py,按照说明执行:
$ sudo python setup.py install
完成安装,很顺序。
然后,本人就找了一个简单的示例来试试。
创建一个文件叫:first_webpy.py,内容如下:
#!/usr/bin/env python import web urls = (‘/(.*)‘, ‘hello‘) class hello: def GET(self, name): i = web.input(times = 1) if not name : name = ‘world‘ for c in xrange(int(i.times)): print ‘Hello, ‘ + name + ‘!‘ app = web.application(urls, globals()) app.run()
然后执行这个文件:
$ python first_webpy.py 2008 #指定端口2008
然后我在本地机器上打开浏览器,在地址栏输入:http://192.168.1.103:2008/h
结果有点失望,显示的结果是:
终端显示为:
192.168.1.103:37506 - - [29/Jul/2014 23:22:26] "HTTP/1.1 GET /favicon.ico" - 500 Internal Server Error http://0.0.0.0:2008/ Traceback (most recent call last): File "/usr/lib/python2.6/site-packages/web.py-0.37-py2.6.egg/web/application.py", line 237, in process return p(lambda: process(processors)) File "/usr/lib/python2.6/site-packages/web.py-0.37-py2.6.egg/web/application.py", line 565, in processor h() File "/usr/lib/python2.6/site-packages/web.py-0.37-py2.6.egg/web/application.py", line 77, in reload_mapping mod = __import__(module_name, None, None, [‘‘]) File "/home/hevake_lcj/Workspace/Python/webpy/first_webpy.py", line 17, in <module> app.run() File "/usr/lib/python2.6/site-packages/web.py-0.37-py2.6.egg/web/application.py", line 313, in run return wsgi.runwsgi(self.wsgifunc(*middleware)) File "/usr/lib/python2.6/site-packages/web.py-0.37-py2.6.egg/web/wsgi.py", line 54, in runwsgi return httpserver.runsimple(func, validip(listget(sys.argv, 1, ‘‘))) File "/usr/lib/python2.6/site-packages/web.py-0.37-py2.6.egg/web/httpserver.py", line 157, in runsimple server.start() File "/usr/lib/python2.6/site-packages/web.py-0.37-py2.6.egg/web/wsgiserver/__init__.py", line 1753, in start raise socket.error(msg) error: No socket could be created 192.168.1.103:37506 - - [29/Jul/2014 23:22:26] "HTTP/1.1 GET /favicon.ico" - 500 Internal Server Error
暂时还没有找到解决方案。
请问,这个为什么有出“No socket could be created”这种错误?
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。