Last active
December 17, 2015 11:19
-
-
Save akademic/5601680 to your computer and use it in GitHub Desktop.
Show popup when recieve http POST JSON message
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
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