【发布时间】:2019-11-18 22:44:04
【问题描述】:
我是烧瓶和网络开发的新手。按下网页上的按钮后,我想在本地 Web 服务器上显示图像。我正在使用 Flask。我一直在尝试解决这个问题,但也无法解决,所以任何帮助都会令人难以置信。 烧瓶代码:
@app.route('/graph_select')
def graph_select():
return render_template('live_stream.html')
@app.route('/read_ph', methods=["GET"])
def ph_plot():
if request.method == "GET":
all_plots.ph_plot()
return render_template('live_stream.html')
@app.route("/read_temp", methods=["GET"])
def temp_plot():
if request.method == "GET":
all_plots.temperature_plot()
return render_template('live_stream.html')
@app.route('/read_distance', methods=["GET"])
def distance_plot():
if request.method == "GET":
all_plots.distance_plot()
return render_template('live_stream.html')
HTML 代码:
<h1>Data Monitoring Station</h1>
<form method="GET"
<a href="read_temp"><button type="button">Temperature Graph</button></a>
<a href="read_ph"><button type="button">PH Graph</button></a>
<a href="read_distance"><button type="button">Distance Graph</button></a>
</form>
<h3><img src="{{ url_for('static', filename='ph_plot.png') }}" width="30%">$
<h3><img src="{{ url_for('static', filename='temperature_plot.png') }}" width="30%">$
<h3><img src="{{ url_for('static', filename='distance_plot.png') }}" width="30%">$
</body>
</html>
【问题讨论】: