Update server.py
This commit is contained in:
parent
57eaf3ee57
commit
011f90cca6
1 changed files with 21 additions and 0 deletions
21
server.py
21
server.py
|
@ -63,6 +63,27 @@ def relay():
|
||||||
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)
|
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:
|
||||||
|
try:
|
||||||
|
if frline and i.decode() != "\n":
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
frline = False
|
||||||
|
except:
|
||||||
|
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