aboutsummaryrefslogtreecommitdiff
path: root/wsgi.py
diff options
context:
space:
mode:
Diffstat (limited to 'wsgi.py')
-rw-r--r--wsgi.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/wsgi.py b/wsgi.py
new file mode 100644
index 0000000..49224b9
--- /dev/null
+++ b/wsgi.py
@@ -0,0 +1,19 @@
1#!/usr/bin/env python3.6
2
3import time
4import re
5import subprocess
6from cgi import parse_qs
7
8def application(environ, start_response):
9 d = parse_qs(environ['QUERY_STRING'])
10
11 start_response('200 OK', [('Content-Type', 'text/plain')])
12 if re.match('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', d.get('ip', ['0'])[0]):
13 ip = d.get('ip', ['0'])[0].encode()
14 if re.match('[0-9a-z]+', d.get('host', [''])[0]):
15 host = d.get('host', ['0'])[0].encode()
16 yield(subprocess.run(["/usr/local/bin/pdnsutil", "delete-rrset", "wire-me.de", host, "A"], stdout=subprocess.PIPE).stdout)
17 yield(subprocess.run(["/usr/local/bin/pdnsutil", "add-record", "wire-me.de", host, "A", ip], stdout=subprocess.PIPE))
18 yield(subprocess.run(["/usr/local/bin/pdnsutil", "list-zone", "wire-me.de"], stdout=subprocess.PIPE).stdout)
19
..