Python 在我的网页html中查看Popen输出?
我无法在页面上显示命令的输出。该命令仅在终端执行。播放Popen如何输出到html页面 app.pyPython 在我的网页html中查看Popen输出?,python,html,flask,Python,Html,Flask,我无法在页面上显示命令的输出。该命令仅在终端执行。播放Popen如何输出到html页面 app.py from subprocess import Popen,PIPE from flask import Flask, render_template app = Flask(__name__) @app.route("/") def index(): return render_template('index.html') @app.route('/page/o
from subprocess import Popen,PIPE
from flask import Flask, render_template
app = Flask(__name__)
@app.route("/")
def index():
return render_template('index.html')
@app.route('/page/one')
def one():
p = Popen(['tail','-f', '/var/log/syslog'],stdout=PIPE,stderr=PIPE)
out,err = p.communicate()
dt0 = out.decode('utf-8')
return render_template('one.html',dt0=dt0)
if __name__=="__main__":
app.run(debug=True)
one.html
<!DOCTYPE html>
<html>
<head>
<title>IT TEst</title>
<body>
<div class="one">
<h2>Output data</h2>
{{dt0}}
</div>
</body>
</head>
</html>
{{end}}
IT测试
输出数据
{{dt0}}
{{end}