猿问

请问,在note页面中应该如何接收?我已经试过用字典形式但是不行。

在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" >


哈士奇WWW
浏览 119回答 1
1回答

慕侠2389804

note 页定义一个新的路由urls&nbsp;=&nbsp;(&nbsp;&nbsp;&nbsp;&nbsp;'/',&nbsp;'index',&nbsp;&nbsp;&nbsp;&nbsp;'/note/(.*)',&nbsp;'Notepage'&nbsp;&nbsp;#&nbsp;超链接传入note)然后在Note控制器中获得地址栏传入的idclass&nbsp;Notepage:&nbsp;&nbsp;&nbsp;&nbsp;def&nbsp;GET(self,&nbsp;note):&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;render.notepage(note)这样就能在notepage.html这个模板中调用了,跟你的index差不多
随时随地看视频慕课网APP

相关分类

Python
我要回答