python作为后端,HTML作为前端

2024-05-08 22:02:56 发布

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

我正在构建一个简单的web应用程序,使用HTML和Python在画布上显示图像。我也在使用烧瓶框架。 图片从HTML上传,在Opencv(Python)中处理,然后显示在HTML制作的画布上, 到目前为止我所做的只是上传图片。但我不能在画布上显示。在

这是CSS和HTML代码

p { font-family: verdana; font-size: 20px; } h2 { margin-left: 20px; text-align: center; } ^{pr2}$

和Python代码

from flask import Flask, render_template, request
import cv2

app = Flask(__name__)

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

@app.route('/hello', methods=['GET','POST'])
def hello():
        if request.method == 'POST':
            image = request.form['Image']
            get_image = cv2.imread(image,0)
            return cv2.imshow(get_image)
        else:
            return render_template('test.html')


if __name__ == '__main__':
    app.run(host = 'localhost', port = 3000, debug=True)

请告诉我我错过了什么,出了什么问题!!谢谢


Tags: 代码nameimageimportappflaskreturnrequest