玩webpy记
2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>
本人從來沒有接觸過web編程,突然對這個(gè)產(chǎn)生了興趣。本人之前學(xué)過一些Python語言,有點(diǎn)基礎(chǔ)。看到網(wǎng)上有很多關(guān)于Python的網(wǎng)絡(luò)開發(fā)的資料,于是想玩一玩。
我所了解的Python網(wǎng)絡(luò)開發(fā)框架有django, webpy。由于本人在web上沒有什么基礎(chǔ),于是決定從輕量級(jí)的webpy入手。
我這里下載了一個(gè)webpy的源碼。解壓源碼包,發(fā)現(xiàn)里面有個(gè)setup.py,按照說明執(zhí)行:
$?sudo?python?setup.py?install完成安裝,很順序。
然后,本人就找了一個(gè)簡單的示例來試試。
創(chuàng)建一個(gè)文件叫:first_webpy.py,內(nèi)容如下:
#!/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()然后執(zhí)行這個(gè)文件:
$?python?first_webpy.py?2008???#指定端口2008然后我在本地機(jī)器上打開瀏覽器,在地址欄輸入:http://192.168.1.103:2008/h
結(jié)果有點(diǎn)失望,顯示的結(jié)果是:
終端顯示為:
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?processreturn?p(lambda:?process(processors))File?"/usr/lib/python2.6/site-packages/web.py-0.37-py2.6.egg/web/application.py",?line?565,?in?processorh()File?"/usr/lib/python2.6/site-packages/web.py-0.37-py2.6.egg/web/application.py",?line?77,?in?reload_mappingmod?=?__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?runreturn?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?runwsgireturn?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?runsimpleserver.start()File?"/usr/lib/python2.6/site-packages/web.py-0.37-py2.6.egg/web/wsgiserver/__init__.py",?line?1753,?in?startraise?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暫時(shí)還沒有找到解決方案。
請問,這個(gè)為什么有出“No socket could be created”這種錯(cuò)誤?
轉(zhuǎn)載于:https://my.oschina.net/hevakelcj/blog/296040
總結(jié)
- 上一篇: Quartz.Net使用总结
- 下一篇: Parse a document fro