Update server.py

This commit is contained in:
Nova Cat 2025-01-14 15:19:21 -08:00
parent 011f90cca6
commit 870ad564c6

View file

@ -62,28 +62,29 @@ def relay():
num+=1
except:
return f'<!DOCTYPE html>\n<html><head><meta charset="UTF-8"><link rel="stylesheet" href="/style.css"><title>Something went wrong...</title></head><body><h1>Something went wrong...</h1><p>The file that the Gemini server sent couldn\'t be decoded by Gem2Browser.</p></body></html>'
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", "")