在code.py中聲明如下數(shù)據(jù)庫對象db = web.database(dbn='mysql' , user='root' , pw='jackniang#2',db='YoO_database')將數(shù)據(jù)庫對象return到index.html模板class index:
def GET(self): notes = db.select('tab_note') return render.index(notes)在index模板中接收$def with (notes)在頁面遍歷并通過超鏈接方式將單個(gè)記錄結(jié)果傳遞給notepage頁面$for note in notes:
<a href="/note?$note" >
1 回答

慕俠2389804
TA貢獻(xiàn)1719條經(jīng)驗(yàn) 獲得超6個(gè)贊
note 頁定義一個(gè)新的路由
urls = ( '/', 'index', '/note/(.*)', 'Notepage' # 超鏈接傳入note)
然后在Note控制器中獲得地址欄傳入的id
class Notepage: def GET(self, note): return render.notepage(note)
這樣就能在notepage.html這個(gè)模板中調(diào)用了,跟你的index差不多
添加回答
舉報(bào)
0/150
提交
取消