毕业论文写作

毕业设计需求

计算机毕业设计中Python web 框架:web.py

 web.py 是一个Python 的web 框架,它简单而且功能强大。web.py 是公开的,无论用于什么用途都是没有限制的。而且相当的小巧,应当归属于轻量级的web 框架。但这并不影响web.py 的强大,而且使用起来很简单、很直接。在实际应用上,web.py 更多的是学术上的价值,因为你可以看到更多web 应用的底层,这在当今“抽象得很好”的web 框架上是学不到的 :) 如果想了解更多web.py,可以访问web.py 的官方文档。

先感受一下web.py 的简单而强大:

[python] < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljE26JBXMVVmykUdiaABQfLCUA0EzPPnLX5WvQWmcsVicATb7YhpJXrhrA/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="view plain">view plain < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljcu4ibCnEsa3Of5ylxtWtDRMcLuQu6xC8C7u7YUJvTQBGCuQMXOy6qBw/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="copy">copy

  1. import web  

  2.   

  3. urls = (  

  4.     ’/(.*)’‘hello’  

  5. )  

  6.   

  7. app = web.application(urls, globals())  

  8.   

  9. class hello:  

  10.     def GET(self, name):  

  11.         i = web.input(times=1)  

  12.         if not name:   

  13.             name = ’world’  

  14.         for c in xrange(int(i.times)):   

  15.             print ‘Hello,’, name+‘!’  

  16.         return ‘Hello, ’ + name + ‘!’  

  17.   

  18. if __name__ == “__main__”:  

  19.     app.run()  

import web

urls = (
'/(.*)', 'hello'
)

app = web.application(urls, globals())

class hello:
def GET(self, name):
i = web.input(times=1)
if not name:
name = 'world'
for c in xrange(int(i.times)):
print 'Hello,', name+'!'
return 'Hello, ' + name + '!'

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

上面就是一个基于web.py 的完整的Web 应用。将上面的代码保存为文件code.py,在命令行下执行python code.py。然后打开你的浏览器,打开地址:http://localhost:8080 或者 http://localhost:8080/test 没有意外的话(当然要先安装web.py,下面会有介绍),浏览器会显示“Hello, world”或者 “Hello, test”。

Linux 下运行

这是一个最简单的Hello world Web 应用。是不是很简单?!下面将较为详细地介绍下web.py 。

1. 安装

下载 web.py 的安装文件,将下载得到的文件 web.py 解压,进入解压后的文件夹,在命令行下执行:python setup.py install,在Linux 等系统下,需要root 的权限,可以执行:sudo python setup.py install。

 

2. URL 处理

对于一个站点来说,URL 的组织是最重要的一个部分,因为这是用户看得到的部分,而且直接影响到站点是如何工作的,例如:www.baidu.com ,其URLs 甚至是网页界面的一部分。而web.py 以简单的方式就能够构造出一个强大的URLs。

在每个web.py 应用,必须先import web 模块:

[python] < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljE26JBXMVVmykUdiaABQfLCUA0EzPPnLX5WvQWmcsVicATb7YhpJXrhrA/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="view plain">view plain < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljcu4ibCnEsa3Of5ylxtWtDRMcLuQu6xC8C7u7YUJvTQBGCuQMXOy6qBw/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="copy">copy

  1. import web  

import web

现在,我们须要告诉web.py URL 如何组织,让我们以一个简单例子开始:

[python] < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljE26JBXMVVmykUdiaABQfLCUA0EzPPnLX5WvQWmcsVicATb7YhpJXrhrA/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="view plain">view plain < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljcu4ibCnEsa3Of5ylxtWtDRMcLuQu6xC8C7u7YUJvTQBGCuQMXOy6qBw/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="copy">copy

  1. urls = (  

  2.   ’/’‘index’    )  

urls = (
'/', 'index' )

在上面的例子中,第一部分是匹配URL的正则表达式,像//help/faq/item/(\d+)等(\d+将匹配数字)。圆括号表示捕捉对应的数据以便后面使用。第二部分是接受请求的类名称,像indexviewwelcomes.hello(welcomes模块的hello类),或者get_\1\1 会被正则表达式捕捉到的内容替换,剩下来捕捉的的内容将被传递到你的函数中去。(‘index’)是一个类名,匹配的请求将会被发送过去。这行表示我们要URL/(首页)被一个叫index的类处理。

现在我们需要创建一个列举这些 url 的 application。

[python] < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljE26JBXMVVmykUdiaABQfLCUA0EzPPnLX5WvQWmcsVicATb7YhpJXrhrA/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="view plain">view plain < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljcu4ibCnEsa3Of5ylxtWtDRMcLuQu6xC8C7u7YUJvTQBGCuQMXOy6qBw/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="copy">copy

  1. app = web.application(urls, globals())  

app = web.application(urls, globals())

 

GET 和 POST : 区别

现在,我们需要编写index 类。当大部人浏览网页的时候,他们都没有注意到,浏览器是通过HTTP 跟World Wide Web 通信的。通信的细节不太重要,但要明白一点,用户是通过URLs(例如 / 或者 /foo?f=1)来请求web 服务器完成一定请求的(例如 GET 或者POST)。

GET 是最普遍的方法,用来请求一个页面。当我们在浏览器里输入“harvard.edu” 的时候,实际上它是向Web 服务器请求GET ”/“。另一个常见的方法是POST,常用于提交特定类型的表单,比如请求买什么东西。每当提交一个去做什么事情(像使用信用卡处理一笔交易)的请求时,你可以使用POST。这是关键,因为GET的URL可以明文传输提交的参数。如果提交的是一些重要的敏感信息,例如用户名,密码,则可能被别人抓包获取到。而 POST 则不会在 URL 上传输 提交的信息,POST 是通过表单提交信息。

在我们的web.py 代码中。我们清晰区分这两种方法:

[python] < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljE26JBXMVVmykUdiaABQfLCUA0EzPPnLX5WvQWmcsVicATb7YhpJXrhrA/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="view plain">view plain < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljcu4ibCnEsa3Of5ylxtWtDRMcLuQu6xC8C7u7YUJvTQBGCuQMXOy6qBw/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="copy">copy

  1. class index:  

  2.     def GET(self):  

  3.         print “Hello, world!”  

class index:
def GET(self):
print "Hello, world!"

当接收到一个GET 请求时,上面的GET 方法将会被web.py 调用。好的。现在,我们只需添加最后一行代码,让web.py 启动网页应用:

[python] < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljE26JBXMVVmykUdiaABQfLCUA0EzPPnLX5WvQWmcsVicATb7YhpJXrhrA/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="view plain">view plain < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljcu4ibCnEsa3Of5ylxtWtDRMcLuQu6xC8C7u7YUJvTQBGCuQMXOy6qBw/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="copy">copy

  1. if __name__ == “__main__”:  

  2.     app.run()  

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

上面告诉web.py 如何配置URLs,以及找寻的类在文件中的全局命名空间。然后为我们启动上面的应用。

整个 code.py 文件的内容如下:

[python] < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljE26JBXMVVmykUdiaABQfLCUA0EzPPnLX5WvQWmcsVicATb7YhpJXrhrA/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="view plain">view plain < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljcu4ibCnEsa3Of5ylxtWtDRMcLuQu6xC8C7u7YUJvTQBGCuQMXOy6qBw/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="copy">copy

  1. import web  

  2.   

  3. urls = (  

  4.     ’/(.*)’‘hello’  

  5. )  

  6.   

  7. app = web.application(urls, globals())  

  8.   

  9. class hello:  

  10.     def GET(self, name):  

  11.         i = web.input(times=1)  

  12.         if not name:   

  13.             name = ’world’  

  14.         for c in xrange(int(i.times)):   

  15.             print ‘Hello,’, name+‘!’  

  16.         return ‘Hello, ’ + name + ‘!’  

  17.   

  18. if __name__ == “__main__”:  

  19.     app.run()  

import web

urls = (
'/(.*)', 'hello'
)

app = web.application(urls, globals())

class hello:
def GET(self, name):
i = web.input(times=1)
if not name:
name = 'world'
for c in xrange(int(i.times)):
print 'Hello,', name+'!'
return 'Hello, ' + name + '!'

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

实际上web 应用的代码就只得上面的几行,而且这是一个完整的web.py 应用。

 

3.启动服务

在你的命令行下输入:

[python] < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljE26JBXMVVmykUdiaABQfLCUA0EzPPnLX5WvQWmcsVicATb7YhpJXrhrA/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="view plain">view plain < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljcu4ibCnEsa3Of5ylxtWtDRMcLuQu6xC8C7u7YUJvTQBGCuQMXOy6qBw/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="copy">copy

  1. &nbsp;python&nbsp;code.py&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">#&nbsp;使用默认端口&nbsp;8080</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span>或者&nbsp;&nbsp;</span></li><li class="alt"><span> python code.py 10000                         # 改变端口为 10000  

$ python code.py                               # 使用默认端口 8080
或者
$ python code.py 10000 # 改变端口为 10000

你的web.py 应用已经启动了服务器。通过浏览器访问:http://localhost:8080/ ,会见到”Hello, world!“。

修改默认端口

在启动服务器的时候,如果你不想使用默认端口,你可以使用这样的命令来指定端口号: python code.py 8888。

 

4. 调试

直接添加一行 web.internalerror = web.debugerror 即可。如下

 

[python] < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljE26JBXMVVmykUdiaABQfLCUA0EzPPnLX5WvQWmcsVicATb7YhpJXrhrA/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="view plain">view plain < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljcu4ibCnEsa3Of5ylxtWtDRMcLuQu6xC8C7u7YUJvTQBGCuQMXOy6qBw/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="copy">copy

  1. if __name__==“__main__”:  

  2.     web.internalerror = web.debugerror  

  3.     app.run()  

if __name__=="__main__":
web.internalerror = web.debugerror
app.run()

 

 

5. 模板

更多关于 web.py templates 可以访问    http://webpy.org/docs/0.3/templetor.zh-cn

在Python 里面编写HTML 代码是相当累赘的,而在HTML 里嵌入Python 代码则有趣得多。幸运地,web.py 使这过程变得相当容易。

注意:旧版本的web.py 是用Cheetah templates 模板的,你可以继续使用,但官方已不再提供支持。

新建一个 code.py 的 python文件。内容如下:

 

[python] < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljE26JBXMVVmykUdiaABQfLCUA0EzPPnLX5WvQWmcsVicATb7YhpJXrhrA/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="view plain">view plain < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljcu4ibCnEsa3Of5ylxtWtDRMcLuQu6xC8C7u7YUJvTQBGCuQMXOy6qBw/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="copy">copy

  1. import web  

  2.   

  3.   

  4. urls = (  

  5.     # ’/(.*)’, ‘hello’,  

  6.     ’/hello_1[/]?.*’‘hello_1’,  

  7.     ’/hello_2/(.*)’‘hello_2’,  

  8. )  

  9.   

  10. app = web.application(urls, globals())  

  11. render=web.template.render(’templates’)  

  12.   

  13. class hello_1:  

  14.   

  15.     def GET(self):          

  16.         return render.index_1()   

  17.   

  18.   

  19. class hello_2:  

  20.   

  21.     def GET(self, name):          

  22.         return render.index_2(“Lisa”)   

  23.           

  24. if __name__ == “__main__”:  

  25.     app.run()  

import web


urls = (
# '/(.*)', 'hello',
'/hello_1[/]?.*', 'hello_1',
'/hello_2/(.*)', 'hello_2',
)

app = web.application(urls, globals())
render=web.template.render('templates')

class hello_1:

def GET(self):
return render.index_1()


class hello_2:

def GET(self, name):
return render.index_2("Lisa")

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

 

创建模板

这里,我们先在项目 code.py 同一级目录中新建一个目录(例如 templates )集中存放并用来组织模板文件,便于管理。然后在templates下新建HTML 文件(例如:”index.html“)。这里新建 两个 HTML 文件。 index_1.html 和 index_2.html

index_1.html 文件内容如下:

[html] < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljE26JBXMVVmykUdiaABQfLCUA0EzPPnLX5WvQWmcsVicATb7YhpJXrhrA/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="view plain">view plain < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljcu4ibCnEsa3Of5ylxtWtDRMcLuQu6xC8C7u7YUJvTQBGCuQMXOy6qBw/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="copy">copy

  1. <em>Hello</em>, world!  

<em>Hello</em>, world!

这是一个最简单的html页面代码。

index_2.html 文件内容如下:

[html] < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljE26JBXMVVmykUdiaABQfLCUA0EzPPnLX5WvQWmcsVicATb7YhpJXrhrA/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="view plain">view plain < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljcu4ibCnEsa3Of5ylxtWtDRMcLuQu6xC8C7u7YUJvTQBGCuQMXOy6qBw/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="copy">copy

  1. def&nbsp;with&nbsp;(name)&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;</span></li><li class="alt"><span>&lt;!DOCTYPE&nbsp;html&nbsp;PUBLIC&nbsp;"-//W3C//DTD&nbsp;XHTML&nbsp;1.0&nbsp;Strict//EN"&nbsp;"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"<span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span><span class="tag">&lt;</span><span class="tag-name">html</span><span>&nbsp;</span><span class="attribute">xmlns</span><span>=</span><span class="attribute-value">"http://www.w3.org/1999/xhtml"</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span><span class="tag">&lt;</span><span class="tag-name">head</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="tag">&lt;</span><span class="tag-name">meta</span><span>&nbsp;</span><span class="attribute">http-equiv</span><span>=</span><span class="attribute-value">"Content-Type"</span><span>&nbsp;</span><span class="attribute">content</span><span>=</span><span class="attribute-value">"text/html;&nbsp;charset=utf-8"</span><span>&nbsp;</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="tag">&lt;</span><span class="tag-name">title</span><span class="tag">&gt;</span><span>Template</span><span class="tag">&lt;/</span><span class="tag-name">title</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span><span class="tag">&lt;/</span><span class="tag-name">head</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span><span class="tag">&lt;</span><span class="tag-name">body</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;Hi,&nbsp;name  

  2. </body>  

  3. </html>  

$def with (name)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Template</title>
</head>
<body>
Hi, $name
</body>
</html>

注意上面代码的缩进!

正如你所见的,上面的模板看上去跟这Python 文件很相似,以def with 语句开始,但在关键字前需要添加”$“。

注意:在模板内的变量,如果包含有HTML 标记,以$ 方式引用变量的话,HTML 标记只会以纯文本的显示出来。要想HTML 标记产生效果,可以用$: 引用变量。

 

使用模板

现在,回到 code.py 文件,在”import web” 的下一行添加:

[python] < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljE26JBXMVVmykUdiaABQfLCUA0EzPPnLX5WvQWmcsVicATb7YhpJXrhrA/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="view plain">view plain < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljcu4ibCnEsa3Of5ylxtWtDRMcLuQu6xC8C7u7YUJvTQBGCuQMXOy6qBw/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="copy">copy

  1. render = web.template.render(‘templates/’)  

render = web.template.render('templates/')

这告诉web.py 在哪里可以搜索得到模板目录。提示:可在render 调用里添加cache = False 使得每次访问页面时都重载模板。

然后再修改使用这个模板的类,在这里  修改 类 hello_1 和 类 hello_2

[python] < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljE26JBXMVVmykUdiaABQfLCUA0EzPPnLX5WvQWmcsVicATb7YhpJXrhrA/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="view plain">view plain < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljcu4ibCnEsa3Of5ylxtWtDRMcLuQu6xC8C7u7YUJvTQBGCuQMXOy6qBw/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="copy">copy

  1. class hello_1:  

  2.   

  3.     def GET(self):  

  4.         return render.index_1()   

  5.   

  6.   

  7. class hello_2:  

  8.   

  9.     def GET(self, name):  

  10.         # name = “Lisa”  

  11.         return render.index_2(“Lisa”)   

class hello_1:

def GET(self):
return render.index_1()


class hello_2:

def GET(self, name):
# name = "Lisa"
return render.index_2("Lisa")

上面的 ”index_1“ 和 “index_2” 是模板的名字,”Lisa“ 是传递过去的参数。

同时修改urls为:

[python] < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljE26JBXMVVmykUdiaABQfLCUA0EzPPnLX5WvQWmcsVicATb7YhpJXrhrA/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="view plain">view plain < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljcu4ibCnEsa3Of5ylxtWtDRMcLuQu6xC8C7u7YUJvTQBGCuQMXOy6qBw/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="copy">copy

  1. urls = (  

  2.     # ’/(.*)’, ‘hello’,  

  3.     ’/hello_1[/]?.*’‘hello_1’,  

  4.     ’/hello_2/(.*)’‘hello_2’,  

  5. )  

urls = (
# '/(.*)', 'hello',
'/hello_1[/]?.*', 'hello_1',
'/hello_2/(.*)', 'hello_2',
)

上面的“/(.*)” 是一个正则表达式。括号里面是要传递的参数。再将GET 方法修改如下:

 

[python] < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljE26JBXMVVmykUdiaABQfLCUA0EzPPnLX5WvQWmcsVicATb7YhpJXrhrA/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="view plain">view plain < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljcu4ibCnEsa3Of5ylxtWtDRMcLuQu6xC8C7u7YUJvTQBGCuQMXOy6qBw/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="copy">copy

  1. def GET(self,name):  

  2.     print render.index_2(name)  

def GET(self,name):
print render.index_2(name)

hello_1 页面调用 hello_1 类,使用 index_1.html 模板。打开 http://localhost:8080/hello_1 ,页面就会打印出 Hello, world 的字样。

hello_2/ 页面调用 hello_2 类,使用 index_2.html 模板,打开 http://localhost:8080/hello_2/,页面就会打印出 Hello, Lisa 的字样。

 

除此之外还有两种使用模板的方法

  1. 使用frender直接指定模板文件。GET函数最后两行改为

    [python] < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljE26JBXMVVmykUdiaABQfLCUA0EzPPnLX5WvQWmcsVicATb7YhpJXrhrA/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="view plain">view plain < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljcu4ibCnEsa3Of5ylxtWtDRMcLuQu6xC8C7u7YUJvTQBGCuQMXOy6qBw/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="copy">copy

      render=web.template.frender("templates/index.html")
    return render("Lisa")
    • 1

    1. render=web.template.frender(“templates/index.html”)  

    2. return render(“Lisa”)  

  2. 直接在代码里写出模板文件。GET最后两行改为

    [python] < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljE26JBXMVVmykUdiaABQfLCUA0EzPPnLX5WvQWmcsVicATb7YhpJXrhrA/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="view plain">view plain < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljcu4ibCnEsa3Of5ylxtWtDRMcLuQu6xC8C7u7YUJvTQBGCuQMXOy6qBw/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="copy">copy

      template = "$def with (name)\nHello $name"
    render = web.template.Template(template)
    return render("Lisa")
    1. template = def&nbsp;with&nbsp;(name)\nHello&nbsp;name”  

    2. render = web.template.Template(template)  

    3. return render(“Lisa”)  

 

模板含义

现在解释一下这个 index.html 模板的含义:

[html] < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljE26JBXMVVmykUdiaABQfLCUA0EzPPnLX5WvQWmcsVicATb7YhpJXrhrA/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="view plain">view plain < data-linktype="2" rel="noopener noreferrer" style="box-sizing: border-box;outline: none;margin-right: 10px;padding: 1px;cursor: pointer;background-color: inherit;color: rgb(103, 149, 181);background-image: url("https://mmbiz.qpic.cn/mmbiz_png/Je6BX9J7ZicXkBvdlB21LLlfO5FoicrPljcu4ibCnEsa3Of5ylxtWtDRMcLuQu6xC8C7u7YUJvTQBGCuQMXOy6qBw/640?wx_fmt=gif");background-position: left top;background-size: initial;background-repeat: no-repeat;background-attachment: initial;background-origin: initial;background-clip: initial;border-width: initial;border-style: none;border-color: initial;overflow-wrap: break-word;display: inline-block;width: 16px;height: 16px;text-indent: -2000px;" target="_self" title="copy">copy

  1. def&nbsp;with&nbsp;(name)&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;</span></li><li class="alt"><span>&lt;!DOCTYPE&nbsp;html&nbsp;PUBLIC&nbsp;"-//W3C//DTD&nbsp;XHTML&nbsp;1.0&nbsp;Strict//EN"&nbsp;"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"<span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span><span class="tag">&lt;</span><span class="tag-name">html</span><span>&nbsp;</span><span class="attribute">xmlns</span><span>=</span><span class="attribute-value">"http://www.w3.org/1999/xhtml"</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span><span class="tag">&lt;</span><span class="tag-name">head</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="tag">&lt;</span><span class="tag-name">meta</span><span>&nbsp;</span><span class="attribute">http-equiv</span><span>=</span><span class="attribute-value">"Content-Type"</span><span>&nbsp;</span><span class="attribute">content</span><span>=</span><span class="attribute-value">"text/html;&nbsp;charset=utf-8"</span><span>&nbsp;</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="tag">&lt;</span><span class="tag-name">title</span><span class="tag">&gt;</span><span>Template</span><span class="tag">&lt;/</span><span class="tag-name">title</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span><span class="tag">&lt;/</span><span class="tag-name">head</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class="alt"><span><span class="tag">&lt;</span><span class="tag-name">body</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li><li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;Hi,&nbsp;name  

  2. </body>  

  3. </html>  

$def with (name)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Template</title>
</head>
<body>
Hi, $name
</body>
</html>

在index.html第一行 $def with (name)表示本模板接受一个名为name的参数,也就是对应index类中return render.index(“Lisa”)中的Lisa。

而render=web.template.render(“templates”)表示创建一个模板对象,模板是存放于templates目录下,然后就可以用所创建的 render 对象来访问相应的模板

比如templates目录下的index.html就是用render.index来表示(实际上是匹配寻找index.*文件,第一个匹配的就认为是所对应的模板文件),如果templates下还有个a目录,a目录下有个pagea.html,那么访问这个pagea模板就要用render.a.pagea的形式了。

最新毕业设计成品

版权所有© 帮我毕业网 并保留所有权利

QQ 1370405256 微信 biyebang

QQ:629001810微信:biyebang

收缩