From d4dc2f603bcc8eb0c85fb65fea5f9b02e3cdd8f3 Mon Sep 17 00:00:00 2001 From: swee Date: Mon, 13 Jan 2025 20:27:09 -0800 Subject: [PATCH] Update server.py --- server.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 required

Input 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: