1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > python flask 实现电脑屏幕实时共享

python flask 实现电脑屏幕实时共享

时间:2018-07-07 05:24:17

相关推荐

python flask 实现电脑屏幕实时共享

在A电脑上运行以下脚本后,在B电脑上通过链接“http://192.168.3.6:5000/viedo_feed”即可看到A电脑的实时动态屏幕图像。

import pyautoguifrom flask import Flask, render_template, Responseimport ioapp = Flask(__name__)@app.route('/')def index():return render_template('index.html')def gen():while True:#截屏screenShotImg = pyautogui.screenshot()#截屏转换成图像数据imgByteArr = io.BytesIO()screenShotImg.save(imgByteArr, format='JPEG')imgByteArr = imgByteArr.getvalue()frame = imgByteArr#截屏图像数据分帧生成yield (b'--frame\r\n Content-Type: image/jpeg\r\n\r\n' + frame)@app.route('/video_feed')def video_feed():#分帧推送截屏图像数据到前端return Response(gen(), mimetype='multipart/x-mixed-replace; boundary=frame')if __name__ == '__main__':app.run(host='0.0.0.0', debug=False, threaded=True, port=5000)

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。