diff --git a/server.py b/server.py
index e8f10c9..edd1603 100644
--- a/server.py
+++ b/server.py
@@ -39,16 +39,17 @@ def style():
@app.route("/gem")
def relay():
url = request.args.get('gemini')
+ queries = request.args.get('query')
if url == None:
return redirect("/")
code = "
Something went wrong...
\n"
title = "Something went wrong..."
try:
gsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- fulladdr = "gemini://" + url
+ fulladdr = "gemini://" + url + ("?" + queries if queries != None else "")
gemsocket = ssl._create_unverified_context().wrap_socket(gsocket, server_hostname=urlparse(fulladdr).hostname)
gemsocket.connect((urlparse(fulladdr).hostname, 1965))
- gemsocket.send(bytes("gemini://" + url + "\r\n", "UTF-8"))
+ gemsocket.send(bytes(fulladdr + "\r\n", "UTF-8"))
received = ""
while True:
gemresponse = gemsocket.recv(2048)
@@ -70,6 +71,8 @@ def relay():
if firstline:
if i.split(" ")[0][0] == "3":
return redirect("/gem?gemini=" + i.split(" ")[1][9:])
+ elif i.split(" ")[0][0] == "1":
+ return f'\nInput requiredInput required
The specified Gemini server wants more data: "
{i}
"
'
elif i.split(" ")[0][0] != "2":
return f'\nSomething went wrong...Something went wrong...
The specified Gemini server returned a status of: {i}
'
else: