如何使用opencv from Flask在静态文件夹中显示新保存的图像?

2024-04-25 22:01:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图采取图像输入和做一些处理,然后在网页上显示输出。但是,当我尝试其他图像时,显示的是旧图像而不是新图像。在

以下是代码片段:

from flask import Flask, render_template, request

import pro

app = Flask(__name__)


@app.route('/')
def index():
    return render_template("index.html")

@app.route('/process', methods=['GET', 'POST'])
def process():
    n = '/home/vivek/Desktop/CL3/d/booth/trial/uploads/up.jpg'

    a = pro.pro(n)

    return render_template("out.html")

if __name__ == '__main__':
    app.run(debug=True) 

工艺代码:

^{pr2}$

最后是HTML文件:

<!DOCTYPE html>
<html>
<body>
<h2>OUTPUT</h2>
<img src="{{url_for('static', filename='out.jpg')}}" alt="OUTPUT" style="width:128px;height:128px;">
</body>
</html>

Tags: 代码name图像importappflaskindexreturn