python+web.py实现hello world

1,确定系统中存在python环境
以下介绍基于
ubnntu 12.04 amd64
python 2.7.3

2,安装web.py
wget http://webpy.org/static/web.py-0.37.tar.gz
tar -xvzf  web.py-0.37.tar.gz 
cd web.py=0.37
python setup.py install


3,Hello world 编写
david@david-001:~/python$ cat hello.py
#!/usr/bin/python
# filename:hello.py
# -*- coding: UTF-8 -*-

import web

urls = ("/.*", "hello")
app = web.application(urls, globals())

class hello:
    def GET(self):
        return "Hello World!"

if __name__ == '__main__':
    app.run()



4,启动hello world应用
david@david-001:~/python$ python hello.py 127.0.0.1:8000
http://127.0.0.1:8000/


5,测试
david@david-001:~/python$ curl http://127.0.0.1:8000/
Hello World!

你可能感兴趣的:(Web,python,web.py,webpy)