[問題] 如何使用python和flask弄出html網頁

看板Python作者 (貓兒衝鋒)時間4年前 (2020/02/14 20:15), 編輯推噓5(6115)
留言22則, 9人參與, 4年前最新討論串1/1
看一個老外的教學影片,也許是英文不夠好漏掉了什麼,有人知道問題在哪嗎 http://i.imgur.com/3dLNFET.jpg
http://i.imgur.com/t5uGBox.jpg
----- Sent from JPTT on my HUAWEI JKM-LX2. -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 27.52.136.66 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1581682528.A.F83.html

02/14 20:22, 4年前 , 1F
不考慮Django嗎
02/14 20:22, 1F

02/14 20:24, 4年前 , 2F
試試把 index.html 換成 templates/index.html
02/14 20:24, 2F

02/14 20:39, 4年前 , 3F
樓上,仍然失敗,另外return test 有結果,的確是找html
02/14 20:39, 3F

02/14 20:39, 4年前 , 4F
檔的問題
02/14 20:39, 4F

02/14 20:49, 4年前 , 5F
venv目錄內找不到templates目錄
02/14 20:49, 5F

02/14 20:52, 4年前 , 6F
要嘛你的app run的file寫在最外層. 不然比較結構的作法
02/14 20:52, 6F

02/14 20:52, 4年前 , 7F
應該是用application factory搭配blueprint
02/14 20:52, 7F

02/14 20:53, 4年前 , 8F
樓上是對的,先吧 index.py 往上搬一層驗證吧
02/14 20:53, 8F

02/14 21:12, 4年前 , 9F
哈哈,我成功了,感謝各位
02/14 21:12, 9F

02/14 21:16, 4年前 , 10F
另外有人知道怎麼放圖嗎?http://i.imgur.com/siEGp3V.jp
02/14 21:16, 10F

02/14 21:16, 4年前 , 11F
g 結果是讀取不到圖片
02/14 21:16, 11F

02/14 21:25, 4年前 , 12F
通常是用 url_for 去處理,不會直接寫路徑
02/14 21:25, 12F

02/14 21:26, 4年前 , 13F

02/14 21:27, 4年前 , 14F
第二個回答有官方文件連結可以參考
02/14 21:27, 14F

02/15 07:19, 4年前 , 15F
.
02/15 07:19, 15F

02/15 09:22, 4年前 , 16F
static資料夾可以在app=flask(__name__, static_url_pat
02/15 09:22, 16F

02/15 09:22, 4年前 , 17F
h=ooxx)設好
02/15 09:22, 17F

02/15 12:24, 4年前 , 18F
可以去 Github 搜尋 The-Flask-Mega-Tutorial-zh
02/15 12:24, 18F

02/16 16:13, 4年前 , 19F
想學flask推一下開發團隊成員李輝自己寫的書
02/16 16:13, 19F

02/16 16:13, 4年前 , 20F

02/27 21:11, 4年前 , 21F
建議先把官方文件讀過至少tutorials吧,至少知道資
02/27 21:11, 21F

02/27 21:11, 4年前 , 22F
料夾結構怎麼放
02/27 21:11, 22F
文章代碼(AID): #1UHezW-3 (Python)