web.py学习笔记
发布日期:2021-06-30 19:39:20 浏览次数:2 分类:技术文章

本文共 617 字,大约阅读时间需要 2 分钟。

code.py

import web# render = web.template.render('E:\\py_demo\\py_demo\\templates')root = os.path.dirname(__file__)templatesPath=root+'\\templates\\'render = web.template.render(templatesPath)urls = (    '/(.*)', 'index')class index:    def GET(self,name):		i = web.input(name=None)		return render.index(i.name)if __name__ == "__main__":    app = web.application(urls, globals())    app.run()

tmplates/index.html

$def with (name)$if name:    I just wanted to say hello to $name.$else:    Hello, world!

运行code.py

python code.py 127.0.0.1:8080
打开浏览器输入http://127.0.0.1:8080/?name=lin
得到I just wanted to say hello to lin.

转载地址:https://linxinfa.blog.csdn.net/article/details/70952587 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:python的代码缩进
下一篇:web.py框架

发表评论

最新留言

不错!
[***.144.177.141]2024年04月09日 08时46分27秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章