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,8 +62,8 @@ def relay():
num+=1 num+=1
except: 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>' 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>'
if num == 1:
print(mimetype) print(mimetype)
mimetyp = ""
for i in bytes(gemraw): for i in bytes(gemraw):
try: try:
if i.decode() != "\r": if i.decode() != "\r":
@ -71,8 +71,8 @@ def relay():
else: else:
break break
except: except:
print(traceback.format_exc())
break break
mimetype = mimetyp
gr2 = bytearray() gr2 = bytearray()
if not mimetype in ["text/gemini", ""]: if not mimetype in ["text/gemini", ""]:
frline = True frline = True
@ -83,6 +83,7 @@ def relay():
else: else:
frline = False frline = False
except: except:
print(traceback.format_exc())
pass pass
if binary: if binary:
return Response(bytes(gemraw), mimetype="text/gemini" if mimetype=="" else mimetype) return Response(bytes(gemraw), mimetype="text/gemini" if mimetype=="" else mimetype)