mirror of https://gitlab.com/bashrc2/epicyon
Handle options background image
parent
7e19d57cc9
commit
25e30ee60e
90
daemon.py
90
daemon.py
|
@ -1840,37 +1840,6 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
self._benchmarkGETtimings(GETstartTime, GETtimings, 16)
|
self._benchmarkGETtimings(GETstartTime, GETtimings, 16)
|
||||||
|
|
||||||
for ext in ('webp', 'gif', 'jpg', 'png'):
|
|
||||||
# login screen background image
|
|
||||||
if self.path == '/login-background.' + ext:
|
|
||||||
mediaFilename = \
|
|
||||||
self.server.baseDir + '/accounts/login-background.' + ext
|
|
||||||
if os.path.isfile(mediaFilename):
|
|
||||||
if self._etag_exists(mediaFilename):
|
|
||||||
# The file has not changed
|
|
||||||
self._304()
|
|
||||||
return
|
|
||||||
|
|
||||||
tries = 0
|
|
||||||
mediaBinary = None
|
|
||||||
while tries < 5:
|
|
||||||
try:
|
|
||||||
with open(mediaFilename, 'rb') as avFile:
|
|
||||||
mediaBinary = avFile.read()
|
|
||||||
break
|
|
||||||
except Exception as e:
|
|
||||||
print(e)
|
|
||||||
time.sleep(1)
|
|
||||||
tries += 1
|
|
||||||
if mediaBinary:
|
|
||||||
self._set_headers_etag(mediaFilename, 'image/' + ext,
|
|
||||||
mediaBinary, cookie,
|
|
||||||
callingDomain)
|
|
||||||
self._write(mediaBinary)
|
|
||||||
return
|
|
||||||
self._404()
|
|
||||||
return
|
|
||||||
|
|
||||||
# QR code for account handle
|
# QR code for account handle
|
||||||
if '/users/' in self.path and \
|
if '/users/' in self.path and \
|
||||||
self.path.endswith('/qrcode.png'):
|
self.path.endswith('/qrcode.png'):
|
||||||
|
@ -1943,35 +1912,38 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self._benchmarkGETtimings(GETstartTime, GETtimings, 17)
|
self._benchmarkGETtimings(GETstartTime, GETtimings, 17)
|
||||||
|
|
||||||
for ext in ('webp', 'gif', 'jpg', 'png'):
|
for ext in ('webp', 'gif', 'jpg', 'png'):
|
||||||
# follow screen background image
|
for bg in ('follow', 'options', 'login'):
|
||||||
if self.path == '/follow-background.' + ext:
|
# follow screen background image
|
||||||
mediaFilename = \
|
if self.path == '/' + bg + '-background.' + ext:
|
||||||
self.server.baseDir + '/accounts/follow-background.' + ext
|
mediaFilename = \
|
||||||
if os.path.isfile(mediaFilename):
|
self.server.baseDir + '/accounts/' + \
|
||||||
if self._etag_exists(mediaFilename):
|
bg + '-background.' + ext
|
||||||
# The file has not changed
|
if os.path.isfile(mediaFilename):
|
||||||
self._304()
|
if self._etag_exists(mediaFilename):
|
||||||
return
|
# The file has not changed
|
||||||
|
self._304()
|
||||||
|
return
|
||||||
|
|
||||||
tries = 0
|
tries = 0
|
||||||
mediaBinary = None
|
mediaBinary = None
|
||||||
while tries < 5:
|
while tries < 5:
|
||||||
try:
|
try:
|
||||||
with open(mediaFilename, 'rb') as avFile:
|
with open(mediaFilename, 'rb') as avFile:
|
||||||
mediaBinary = avFile.read()
|
mediaBinary = avFile.read()
|
||||||
break
|
break
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
tries += 1
|
tries += 1
|
||||||
if mediaBinary:
|
if mediaBinary:
|
||||||
self._set_headers_etag(mediaFilename, 'image/' + ext,
|
self._set_headers_etag(mediaFilename,
|
||||||
mediaBinary, cookie,
|
'image/' + ext,
|
||||||
callingDomain)
|
mediaBinary, cookie,
|
||||||
self._write(mediaBinary)
|
callingDomain)
|
||||||
return
|
self._write(mediaBinary)
|
||||||
self._404()
|
return
|
||||||
return
|
self._404()
|
||||||
|
return
|
||||||
|
|
||||||
self._benchmarkGETtimings(GETstartTime, GETtimings, 18)
|
self._benchmarkGETtimings(GETstartTime, GETtimings, 18)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue