標籤:http os 檔案 io for 2014 art ar
本人從來沒有接觸過web編程,突然對這個產生了興趣。本人之前學過一些Python語言,有點基礎。看到網上有很多關於Python的網路開發的資料,於是想玩一玩。
我所瞭解的Python網路開發架構有django, webpy。由於本人在web上沒有什麼基礎,於是決定從輕量級的webpy入手。
我這裡下載了一個webpy的源碼。解壓源碼包,發現裡面有個setup.py,按照說明執行:
$ sudo python setup.py install
完成安裝,很順序。
然後,本人就找了一個簡單的樣本來試試。
建立一個檔案叫:first_webpy.py,內容如下:
#!/usr/bin/env pythonimport weburls = (‘/(.*)‘, ‘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 Errorhttp://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 created192.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”這種錯誤?