安装python及web.py


在linux下安装python2.7.x,打开终端:

1, wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz #下载到当前目录
2, tar xvfz Python-2.7.3.tgz #解压
3, cd Python-2.7.3 #进入目录 
4, ./configure
5, make #编译
6, su #转为root用户
7, make altinstall #安装

直至安装完成。


安装web.py,
1, http://webpy.org/static/web.py-0.37.tar.gz
2, tar xvfz web.py-0.37.tar.gz
3, cd web.py-0.37
4, sudo python setup.py install


安装完成后,打开记事本,编写以下代码并保存到web.py-0.37目录下:
import web

urls = (
    '/', 'index'
)

class index:
    def GET(self):
        return 'holle work...'
    
if __name__ == "__main__":
    app = web.application(urls, globals())
    app.run()

将文件存为code.py,然后打开终端进行到web.py-0.37目录下,输入:python code.py,切记保存到web.py-0.37的目录 下,若不是会报No module named web的错.如果在终端里看到http://0.0.0.0:8080/里则说明已经成功启动web.py自带的web服务器。打开浏览器,输入http://localhost:8080,则看到holle,work...



参考文档 http://webpy.org/install.zh-cn

猜你喜欢

转载自tcrct.iteye.com/blog/1845452