web.py 是一个Python 的web 框架,它简单而且功能强大。web.py 是公开的,无论用于什么用途都是没有限制的。而且相当的小巧,应当归属于轻量级的web 框架。但这并不影响web.py 的强大,而且使用起来很简单、很直接。在实际应用上,web.py 更多的是学术上的价值,因为你可以看到更多web 应用的底层,这在当今“抽象得很好”的web 框架上是学不到的 :) 如果想了解更多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
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()
[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
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
urls = (
’/’, ‘index’ )
[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
app = web.application(urls, globals())
[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
class index:
def GET(self):
print “Hello, world!”
[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
if __name__ == “__main__”:
app.run()
[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
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()
[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
python code.py 10000 # 改变端口为 10000
[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
if __name__==“__main__”:
web.internalerror = web.debugerror
app.run()
[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
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()
[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
<em>Hello</em>, world!
[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
name
</body>
</html>
[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.render(‘templates/’)
[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
class hello_1:
def GET(self):
return render.index_1()
class hello_2:
def GET(self, name):
# name = “Lisa”
return render.index_2(“Lisa”)
[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
urls = (
# ’/(.*)’, ‘hello’,
’/hello_1[/]?.*’, ‘hello_1’,
’/hello_2/(.*)’, ‘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
def GET(self,name):
print render.index_2(name)
使用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
1
render=web.template.frender(“templates/index.html”)
return render(“Lisa”)
直接在代码里写出模板文件。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 = “name”
render = web.template.Template(template)
return render(“Lisa”)
[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
name
</body>
</html>
版权所有© 帮我毕业网 并保留所有权利