利用web.py快速搭建网页hellow

发布时间:2019-05-09 21:56:18编辑:auto阅读(2121)

     

     

    访问web.py官网 http://webpy.org/

    SGHBNNIT]}54B}0K8@}GDTW

    根据网站步骤,利用 pip install web.py

    若没有 PIP

    则先安装pip

    运行 

    sudo apt-get install python-pip

    image

    网站安装python 2 ,运行python 3 则需要

    pip install web.py==0.40-dev1

    编写 myweb.py运行脚本
     import web        
     urls = (
         '/(.*)', 'hello'
     )
     app = web.application(urls, globals())
    
     class hello:        
         def GET(self, name):
             if not name: 
                 name = 'World'
             return 'Hello, ' + name + '!'
    
     if __name__ == "__main__":
         app.run()
    利用python myweb.py 运行这个脚本 开启服务 
    也可加后面加入IP 和端口
     
     

关键字