Re: [問題] html 的 frameset已刪文

看板Python作者 (Neisseria)時間11年前 (2014/12/29 16:36), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/3 (看更多)
其實還是 route 的問題 在 HTML 檔案裡設定的路徑,在 Flask app 裡必需要有對應的 route 否則就會跳 404 error (網頁不存在) 我跟據你的程式,試寫了一個可能的 route 但是我手頭上沒有網頁可測試,不保證 work from flask import Flask, send_from_directory app = Flask(__name__) @app.route('/report') def view_report(): return app.send_static_file('report/flexmonkey/html/index.html') @app.route('/<path:filename>') def send_file(filename): return send_from_directory('report/flexmonkey/html', filename) ※ 引述《gn00618777 (非常念舊)》之銘言: : ㄧ個 index.html ,裡面有 frameset tag,分成三區塊,這三個區塊在 index.html : 裡分別代表其他三份 html,例子如下: : <frameset cols="20%,80%"> : <frameset rows="30%,70%"> : <frame src="overview-frame.html" name="packageListFrame"> : <frame src="allclasses-frame.html" name="classListFrame"> : </frameset> : <frame src="overview-summary.html" name="classFrame"> : 我在 flask 下寫一個 script test.py: : @app.route("/") : def hello(): : return "Hello World!" : @app.route("/report") : def view_report(): : url_for('static', filename='report/flexmonkey/html/') : return send_from_directory('static', 'report/flexmonkey/html/index.html') : 所有html都放在 report/flexmonkey/html/ 底下,server 啟動 test.py : 客戶端無法載入其他 html : 127.0.0.1 - - [13/Sep/2012 11:01:25] "GET /overview-frame.html HTTP/1.1" 404 - : 127.0.0.1 - - [13/Sep/2012 11:01:25] "GET /allclasses-frame.html HTTP/1.1" 404 - : 127.0.0.1 - - [13/Sep/2012 11:01:25] "GET /overview-summary.html HTTP/1.1" 404 : 請問這個在 test.py 要怎麼寫呢? 謝謝。 -- Happy Computing - Tips and recipes for Unix and programming http://cwchen123.tw/ Follow me at Twitter https://twitter.com/cwchen123 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 203.71.94.31 ※ 文章網址: http://www.ptt.cc/bbs/Python/M.1419842197.A.35C.html
文章代碼(AID): #1KeHALDS (Python)
討論串 (同標題文章)
本文引述了以下文章的的內容:
以下文章回應了本文
完整討論串 (本文為第 2 之 3 篇):
文章代碼(AID): #1KeHALDS (Python)