web.py在note页面中应该如何接收值的传入,web.pynote,在code.py中声明如
web.py在note页面中应该如何接收值的传入,web.pynote,在code.py中声明如
在code.py中声明如下数据库对象
db = web.database(dbn='mysql' , user='root' , pw='jackniang#2',db='YoO_database')
将数据库对象return到index.html模板
class index:def GET(self):notes = db.select('tab_note')return render.index(notes)
在index模板中接收
$def with (notes)
在页面遍历并通过超链接方式将单个记录结果传递给notepage页面
$for note in notes:<a href="/note?$note" >
请问,在note页面中应该如何接收?我已经试过用字典形式但是不行。
note 页定义一个新的路由
urls = ( '/', 'index', '/note/(.*)', 'Notepage' # 超链接传入note)
然后在Note控制器中获得地址栏传入的id
class Notepage: def GET(self, note): return render.notepage(note)
这样就能在notepage.html这个模板中调用了,跟你的index差不多
编橙之家文章,
相关内容
- Python web make_server方式与直接运行区别是什么,pythonma
- 对于python循环嵌套应用不太理解,求手高指教,python手高
- Python模版功能实现的原理是什么?,python模版,我一直使
- Python如何反向解析固定格式log,python解析格式log,怎样按
- Python有提供类似拼图模块吗,python类似拼图模块,我想在
- 腾讯云VPS主机python flask host 绑定出问题,vpsflask,app.ru
- 新手Flask遇到问题求帮助,新手Flask遇到问题,错误提示
- python web开发书中案例报错ValueError: View function did not r
- Python jQuery将图片URL转换为img 标签方法是什么,,后端使
- python-2.7.5.amd64跑程序时报错ImportError: No module named win3
评论关闭