1. 安装Web.py
    1
    2
    3
    4
    5
    6
    7
    root@bt:~# sudo pip install web.py
    Downloading/unpacking web.py
      Downloading web.py-0.37.tar.gz (90Kb): 90Kb downloaded
      Running setup.py egg_info for package web.py
    Installing collected packages: web.py
      Running setup.py install for web.py
    Successfully installed web.py
  2. Hello,world
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    root@bt:/tmp# cat hello.py
    import web
     
    urls = ("/.*","hello")
    app = web.application(urls, globals())
     
    class hello:
        def GET(self):
            return'hello,world!'
     
    if __name__ == "__main__":
        app.run()

    运行hello.py

    1
    2
    3
    4
    5
    6
    7
    8
    9
    root@bt:/tmp# vim hello.py
    root@bt:/tmp# python hello.py
    http://0.0.0.0:8080/
    127.0.0.1:53159 - - [25/Jun/2014 20:33:52] "HTTP/1.1 GET /" - 200 OK
    127.0.0.1:53159 - - [25/Jun/2014 20:33:52] "HTTP/1.1 GET /favicon.ico" - 200 OK
    127.0.0.1:53159 - - [25/Jun/2014 20:33:53] "HTTP/1.1 GET /favicon.ico" - 200 OK
    127.0.0.1:53164 - - [25/Jun/2014 20:34:05] "HTTP/1.1 GET /" - 200 OK
    127.0.0.1:53164 - - [25/Jun/2014 20:34:05] "HTTP/1.1 GET /favicon.ico" - 200 OK
    127.0.0.1:53164 - - [25/Jun/2014 20:34:05] "HTTP/1.1 GET /favicon.ico" - 200 OK