玩webpy記

來源:互聯網
上載者:User

標籤: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”這種錯誤?

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.