diff --git a/server.py b/server.py index cec934e..142b220 100644 --- a/server.py +++ b/server.py @@ -62,28 +62,29 @@ def relay(): num+=1 except: return f'\n
The file that the Gemini server sent couldn\'t be decoded by Gem2Browser.
' - print(mimetype) - mimetyp = "" - for i in bytes(gemraw): - try: - if i.decode() != "\r": - mimetyp += i.decode() - else: - break - except: - break - mimetype = mimetyp - gr2 = bytearray() - if not mimetype in ["text/gemini", ""]: - frline = True - for i in gemraw: + if num == 1: + print(mimetype) + for i in bytes(gemraw): try: - if frline and i.decode() != "\n": - pass + if i.decode() != "\r": + mimetyp += i.decode() else: - frline = False + break except: - pass + print(traceback.format_exc()) + break + gr2 = bytearray() + if not mimetype in ["text/gemini", ""]: + frline = True + for i in gemraw: + try: + if frline and i.decode() != "\n": + pass + else: + frline = False + except: + print(traceback.format_exc()) + pass if binary: return Response(bytes(gemraw), mimetype="text/gemini" if mimetype=="" else mimetype) received = received.replace("\r", "")