Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 在我的网页html中查看Popen输出?_Python_Html_Flask - Fatal编程技术网

Python 在我的网页html中查看Popen输出?

Python 在我的网页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

我无法在页面上显示命令的输出。该命令仅在终端执行。播放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/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}