Advertisement
Guest User

Untitled

a guest
Mar 1st, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. def index():
  2. return render_template('index.html')
  3.  
  4. def get_frame():
  5. from PIL import ImageGrab
  6. import pyscreenshot as ImageGrab
  7. import ImageGrab
  8. import io
  9. img = ImageGrab.grab()
  10. output = io.BytesIO()
  11. img.save(output, format='PNG')
  12. return (output.getvalue())
  13.  
  14. def index():
  15. return render_template('index.html')
  16.  
  17. def gen():
  18. while True:
  19. frame = get_frame()
  20. yield (b'--framern'
  21. b'Content-Type: image/jpegrnrn' + frame + b'rnrn')
  22.  
  23. app = Flask(__name__)
  24.  
  25.  
  26.  
  27.  
  28. def getData():
  29. import socket
  30. s = socket.socket()
  31. s.bind(('0.0.0.0', 65320))
  32. s.listen(1)
  33. s.accept()
  34. while True:
  35. print s.recv(1024)
  36. import thread
  37. t1 = thread.start_new_thread(getData, ())
  38.  
  39. @app.route('/')
  40. @app.route('/video_feed')
  41. def video_feed():
  42. return Response(gen(),
  43. mimetype='multipart/x-mixed-replace; boundary=frame')
  44. app.run(host='localhost', debug=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement