-
Notifications
You must be signed in to change notification settings - Fork 0
/
webhook.py
37 lines (30 loc) · 1.02 KB
/
webhook.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import os
import subprocess
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
import json
import socket
PORT_NUMBER = 4567
class myHandler(BaseHTTPRequestHandler):
def do_GET(self):
if( len(self.path.split('?')) < 2):
self.send_response(404)
fullrequest = self.path.split('?')[1].split('&')[0]
request = ""
value = ""
if( len(fullrequest.split('=')) < 2):
request = fullrequest
else:
request = fullrequest.split('=')[0]
value = fullrequest.split('=')[1]
if request == "ring":
open("ring", 'w')
self.send_response(200)
else:
print "Unknown request: ", request
if __name__ == '__main__':
try:
server = HTTPServer(("",PORT_NUMBER),myHandler)
print 'Started Server on port ', PORT_NUMBER
server.serve_forever()
except KeyboardInterrupt:
server.socket.close()