Flask Web开发基于Python的Web应用问题
如题我想用循环显示图片,但只能显示
我想增加第4个图片,请问该怎么解决?
程序代码:
from camera import Camera from flask import Flask, render_template, Response app = Flask(__name__) @app.route('/') def index(): return render_template('index.html') def gen(camera): while True: frame = camera.get_frame() 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(): return Response(gen(Camera()), mimetype='multipart/x-mixed-replace; boundary=frame') if __name__ == '__main__': app.run(host='0.0.0.0', threaded=True)
程序代码:
import time import time class Camera(object): def__int__(self): self.frames = [open(f + '.jpg', 'rb).read() for f in ['1', '2', '3']] def get_frame(self): return self.frames[int(time()) % 3]
[此贴子已经被作者于2018-11-4 10:29编辑过]