[問題] template 問題

看板Python作者 (非常念舊)時間10年前 (2015/02/12 16:52), 編輯推噓0(003)
留言3則, 2人參與, 最新討論串1/1
我在 A 資料夾有 a.html a1.html a2.html,a.html內容是 <li class="link"> <a target="main" href="net_interfaces.html"> Network Interfaces </a> </li> 我在 templates 資料夾 有個 b.html,這個html 在我的 python 主程式 是會被 return render_template('b.html', **templateData) 而a.html在 python 主程式中是直接被 return send_from_directory('xx/xx/A','a.html') 我想將 a.html 中的 net_interfaces.html 改成 templates 資料夾中的 html 會找不到URL,輸入完整路徑也無法。只能選擇同在 A 資料夾中的 a1.html or a2.html 請問要怎麼修改讓我能存取到 templates 資料夾中的 html? ps 不是直接用 render_template('b.html',**templateData) 而是希望用 send_from_directory('','a.html'),並且透過a.html內的超連結 存取到 template 裡的 html 。謝謝。 想了一天了~"~ -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 60.251.223.31 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1423731146.A.087.html

02/12 23:27, , 1F
『透過a.html內的超連結存取到 template 裡的 html』
02/12 23:27, 1F

02/12 23:27, , 2F
這件事無法直接用 Flask 辦到, 請乖乖寫 view
02/12 23:27, 2F

02/14 20:02, , 3F
好的,謝謝。
02/14 20:02, 3F
文章代碼(AID): #1Kt6dA27 (Python)
文章代碼(AID): #1Kt6dA27 (Python)