我是Flask的新手,我尝试将图片上传到静态文件夹并使用cv2制作高斯图像
`@app.route('/upload', methods=['GET', 'POST'])
def upload():
if request.method == 'POST' and 'photo' in request.files:
filename = photos.save(request.files['photo'])
return "Your image has been save" + myfunction(filename)
return render_template('upload.html')
`
上传正在运行,但是当我尝试使用cv2使图像成为高斯模糊时 发生错误
RuntimeError:无法访问请求外的配置
@app.route('/upload/filename')
def myfunction(filename):
img = cv2.imread(filename)
gblur = cv2.GaussianBlur(img, (5, 5), 0)
return render_template('show.html', gblur=gblur)
show.html
<body>
{% if gblur %}
<h1>Image Gaussian Blur</h1><br>
<img src="{{ url_for('static', gblur=gblur) }}">
<br><button><a href="{{ url_for('upload') }}">Go back to Upload New Image</a></button>
{% else %}
<h1>no image for whatever reason</h1>
{% endif %}
</body>
任何人都有任何想法?感谢。