Blob


1 #!/usr/bin/env python3
3 # GeminiGet, aka gg
4 # USAGE: ./gg path [port]
6 import os
7 import socket
8 import ssl
9 import urllib.parse
10 import sys
12 hostname = 'localhost'
13 path = sys.argv[1]
15 port = 1965
16 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 = False
22 context.verify_mode = ssl.CERT_NONE
23 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'))