Update server.py
This commit is contained in:
parent
011f90cca6
commit
870ad564c6
1 changed files with 20 additions and 19 deletions
39
server.py
39
server.py
|
@ -62,28 +62,29 @@ 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>'
|
||||||
print(mimetype)
|
if num == 1:
|
||||||
mimetyp = ""
|
print(mimetype)
|
||||||
for i in bytes(gemraw):
|
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:
|
|
||||||
try:
|
try:
|
||||||
if frline and i.decode() != "\n":
|
if i.decode() != "\r":
|
||||||
pass
|
mimetyp += i.decode()
|
||||||
else:
|
else:
|
||||||
frline = False
|
break
|
||||||
except:
|
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:
|
if binary:
|
||||||
return Response(bytes(gemraw), mimetype="text/gemini" if mimetype=="" else mimetype)
|
return Response(bytes(gemraw), mimetype="text/gemini" if mimetype=="" else mimetype)
|
||||||
received = received.replace("\r", "")
|
received = received.replace("\r", "")
|
||||||
|
|
Loading…
Add table
Reference in a new issue