[問題] 在客戶端的網頁顯示
我一個 html檔,運行在 host,他的內容只有 <h1>{{ result }}</h1>,是要給
客戶端看得顯示頁面。
我web主程式,裡面一個function是執行某個指令:
@app.route("/test",methods=['GET','POST'])
def function test():
import subprocess
cmd=subprocess.Popen(['ifconfig','eth0'],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
out,err=cmd.communicate()
templateData={
'result' : out
}
return render_template('xxx.html',**templateData)
他在客戶端顯示的訊息都是連在一起沒有分段,如果我在web主程式打print(out)
他在這邊就像linux顯示那樣整齊,有甚麼比較聰明的辦法可以讓他像顯示在 linux
那樣地顯示在客戶端? 有python提供的API嗎? 謝謝。
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.136.153.30
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1421460743.A.863.html
※ 編輯: gn00618777 (220.136.153.30), 01/17/2015 10:13:05
→
01/17 10:27, , 1F
01/17 10:27, 1F
→
01/17 13:07, , 2F
01/17 13:07, 2F
→
01/17 13:12, , 3F
01/17 13:12, 3F
→
01/17 13:20, , 4F
01/17 13:20, 4F
→
01/17 13:23, , 5F
01/17 13:23, 5F
→
01/17 17:12, , 6F
01/17 17:12, 6F
討論串 (同標題文章)
完整討論串 (本文為第 1 之 2 篇):
問題
0
6