python web.py 框架搭建

2020-03-10  本文已影响0人  万疆璃火
安装web.py
pip install web.py 
url处理:

任何一个网站最重要的部分就是它的url结构,建立一个code.py文件,并写入

import web

urls = (
    '/', 'index',
)


class index:

    def GET(self):

        return "hello, world!"


if __name__ == "__main__":
    app = web.application(urls, globals())
    app.run()
运行,在控制台输入以下命令启动服务。
python code.py 0.0.0.0:8080
image.png

详情请参考:http://webpy.org/docs/0.3/tutorial.zh-cn

上一篇 下一篇

猜你喜欢

热点阅读