forge
Explore
Log in

Don't you dare go Hollow

hezarfen_zeka

Clone
★ 0

0 watching0 forksPython1.9 MiBe01a4faAhmet Kaan Gümüş2 months ago25 commits

_one.py16 lines, 939 bytesHistoryRawDownload
1import base64, json, re, urllib.request, urllib.error
2text = open("/seed/99_dogrula.surql", encoding="utf-8").read()
3lets = "\n".join(l.strip() for l in text.splitlines() if l.strip().startswith("LET "))
4blocks = re.split(r"\n(?=--\s*I\d+:)", text)
5for b in blocks:
6 m = re.match(r"--\s*(I14):", b)
7 if not m: continue
8 body = "\n".join(l for l in b.splitlines() if not l.strip().startswith("--")).strip()
9 req = urllib.request.Request("http://hzk-surreal:8000/sql", data=(lets+"\n"+body).encode())
10 req.add_header("Accept","application/json"); req.add_header("Content-Type","text/plain; charset=utf-8")
11 req.add_header("surreal-ns","hezarfen"); req.add_header("surreal-db","zeka")
12 req.add_header("Authorization","Basic "+base64.b64encode(b"root:root").decode())
13 try:
14 urllib.request.urlopen(req, timeout=120)
15 except urllib.error.HTTPError as e:
16 print(e.read().decode("utf-8","replace")[:700])