Advertisement
Bkmz

webvnc.py

Jan 24th, 2012
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.10 KB | None | 0 0
  1. #!/usr/bin/env python2.7
  2.  
  3. import time
  4. import BaseHTTPServer
  5.  
  6. import threading
  7. import SimpleHTTPServer
  8.  
  9. from subprocess import call
  10.  
  11.  
  12. HOST_NAME = '0.0.0.0' # !!!REMEMBER TO CHANGE THIS!!!
  13. PORT_NUMBER = 8768 # Maybe set this to 9000.
  14.  
  15.  
  16. class MyHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
  17.     def do_HEAD(s):
  18.         s.send_response(200)
  19.         s.send_header("Content-type", "image/png")
  20.         s.end_headers()
  21.     def do_GET(s):
  22.         """Respond to a GET request."""
  23.         s.send_response(200)
  24.         s.send_header("Content-type", "image/png")
  25.         s.end_headers()
  26.         return_code = call("scrot /tmp/screen.png", shell=True)
  27.  
  28.         s.copyfile(open("/tmp/screen.png", "r"), s.wfile)
  29.  
  30. if __name__ == '__main__':
  31.     server_address = ("", PORT_NUMBER)
  32.     server = BaseHTTPServer.HTTPServer(server_address, MyHandler)
  33.     print time.asctime(), "Server Starts - %s:%s" % (HOST_NAME, PORT_NUMBER)
  34.     try:
  35.         server.serve_forever()
  36.     except KeyboardInterrupt:
  37.         server.server_close()
  38.         print time.asctime(), "Server Stops - %s:%s" % (HOST_NAME, PORT_NUMBER)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement