Last active
December 18, 2015 03:29
-
-
Save di/5718209 to your computer and use it in GitHub Desktop.
"VNC" screenshare over HTTP with Python. See: http://dustingram.com/articles/2013/05/29/vnc-screenshare-over-http-with-python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script type="text/javascript"> | |
function reloadpic() { | |
document.images["screen"].src = "screen.png?random=" + new Date().getTime(); | |
setTimeout("reloadpic();", 500); | |
} | |
onload = reloadpic; | |
</script> | |
</head> | |
<body> | |
<img width="100%" id="screen"> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import pyscreenshot | |
import flask | |
from StringIO import StringIO | |
app = flask.Flask(__name__) | |
@app.route('/screen.png') | |
def serve_pil_image(): | |
img_io = StringIO() | |
pyscreenshot.grab().save(img_io, 'PNG', quality=50) | |
img_io.seek(0) | |
return flask.send_file(img_io, mimetype='image/png') | |
@app.route('/') | |
def serve_img(): | |
return flask.render_template('screen.html') | |
if __name__ == "__main__": | |
app.run(host= '0.0.0.0', debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment