Skip to content

Instantly share code, notes, and snippets.

@akademic
Last active December 17, 2015 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akademic/5601680 to your computer and use it in GitHub Desktop.
Save akademic/5601680 to your computer and use it in GitHub Desktop.
Show popup when recieve http POST JSON message
import os
import BaseHTTPServer
import urlparse
import json
class IncomingHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_POST(s):
s.send_response(200)
s.send_header("Content-type", "text/html")
s.end_headers()
length = int(s.headers['Content-length'])
data = json.loads( s.rfile.read(length) )
os.system('kdialog --passivepopup "%s" --title "%s: %s"'%(data['description'], data['service'], data['title']))
return
def run(server_class=BaseHTTPServer.HTTPServer,
handler_class=IncomingHandler):
server_address = ('', 8000)
httpd = server_class(server_address, handler_class)
print 'Starting server, use <Ctrl-C> to stop'
httpd.serve_forever()
run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment