在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" >
1 回答

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