Blob
1 #!/usr/bin/env python33 # GeminiGet, aka gg4 # USAGE: ./gg path [port]6 import os7 import socket8 import ssl9 import urllib.parse10 import sys12 hostname = 'localhost'13 path = sys.argv[1]15 port = 196516 if len(sys.argv) > 2:17 port = int(sys.argv[2])19 s = socket.create_connection((hostname, port))20 context = ssl.SSLContext()21 context.check_hostname = False22 context.verify_mode = ssl.CERT_NONE23 s = context.wrap_socket(s, server_hostname = hostname)24 s.sendall(("gemini://" + hostname + ":" + str(port) + path + "\r\n").encode('UTF-8'))26 fp = s.makefile("rb")27 for line in fp.read().splitlines():28 print(line.decode('UTF-8'))