我正在寻找一种方法,当我单击按钮时,在我的网络应用程序的同一页面上显示通知。这不是表格!只是一个按钮,当我单击它时,如果单击按钮打开,则在屏幕前发送显示一条消息,例如“门已打开”,或者如果单击按钮警报,则发送“警报”。我对烧瓶完全是新手!这是我的代码的一部分:超文本标记语言<html> <head> <link rel = "stylesheet" type= "text/css" href= "{{ url_for('static', filename='main.css') }}" > <title> Security </title> </head> <body> <h1>{{message}} </h1> <img class = "displayed" src="{{ url_for('video_feed') }}"> <div id='container'> <input type="submit" value="Alarm" id="submit"> <input type="submit" value="Ouvrir" id="submit2"> </div> </body></html> app.pyimport cv2 from flask import Flask, render_template, Responsefrom flask import request, redirect, flashapp = Flask(__name__)@app.route("/", methods = ["GET", "POST"])def index(): """Video streaming home page.""" return render_template('index.html', message = 'un intru est detecté')def gen(): """Video streaming generator function.""" img = cv2.imread("detection.jpg") img = cv2.resize(img, (0,0), fx=0.5, fy=0.5) frame = cv2.imencode('.jpg', img)[1].tobytes() yield (b'--frame\r\n'b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')@app.route('/video_feed')def video_feed(): """Video streaming route. Put this in the src attribute of an img tag.""" return Response(gen(), mimetype='multipart/x-mixed-replace; boundary=frame')if __name__ == '__main__': app.secret_key = 'super secret key' app.run(debug=True)
- 2 回答
- 0 关注
- 96 浏览
添加回答
举报
0/150
提交
取消