Content-Length, Flask, Python, заголовок для передачи картинки
В общем, пытался создать картинку, и затем ее вывести, вроде бы должно было работать, но когда задаю Content-Length оно не работает, не знаю в чем беда, прошу помощи, пробовал уже и st_size из os, и len() файла, не работает
def img():
# img()
with open('img.png', 'rb') as f:
timee = time.time()
now = datetime.datetime.utcfromtimestamp(timee)
normal_time = time.localtime(time.mktime(now.timetuple()))
string = f.read()
stat_info = os.stat('img.png')
req = make_response('img.png')
req.headers['Content-Type'] = 'image/png'
req.headers['Content-Disposition'] = 'inline; filename="img.png"'
req.headers['Content-Length'] = stat_info.st_size # тут размер Content-Lenght
req.headers['Expires'] = 'Mon, 26 Jul 1997 05:00:00 GMT'
req.headers['Accept-Ranges'] = 'bytes'
req.headers['Last-Modified'] = time.strftime('%a, %d %b %Y %H:%M:%S', normal_time)
req.headers['Cache-Control'] = 'no-cache, must-revalidate'
req.headers['Cache-Control'] = 'post-check=0,pre-check=0'
req.headers['Cache-Control'] = 'max-age=0'
req.headers['Pragma'] = 'no-cache'
print(stat_info.st_size)
print(len(string))
print(Response())
return req
По итогу такая ошибка:
Если упустить Content-Lenght, то ничего не выводится, черный квадрат с белыми рамками
