mirror of
https://github.com/FAUSheppy/python-flask-picture-factory
synced 2025-12-06 07:01:37 +01:00
use correct mimetype when re-encoding
This commit is contained in:
@@ -88,7 +88,8 @@ def sendPicture(path):
|
|||||||
scaleX = round(float(x2))
|
scaleX = round(float(x2))
|
||||||
|
|
||||||
pathDebug = path
|
pathDebug = path
|
||||||
path = generatePicture(path, scaleX, scaleY, flask.request.args.get("encoding"),
|
encoding = flask.request.args.get("encoding")
|
||||||
|
path = generatePicture(path, scaleX, scaleY, encoding,
|
||||||
bool(flask.request.args.get("crop")))
|
bool(flask.request.args.get("crop")))
|
||||||
if not path:
|
if not path:
|
||||||
return ("File not found: {}".format(os.path.join(PICTURE_DIR, pathDebug)), 404)
|
return ("File not found: {}".format(os.path.join(PICTURE_DIR, pathDebug)), 404)
|
||||||
@@ -107,6 +108,9 @@ def sendPicture(path):
|
|||||||
else:
|
else:
|
||||||
response.headers['Cache-Control'] = "max-age=" + "3600"
|
response.headers['Cache-Control'] = "max-age=" + "3600"
|
||||||
|
|
||||||
|
if encoding:
|
||||||
|
response.headers['Content-Type'] = "image/{}".format(encoding)
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
|
|||||||
Reference in New Issue
Block a user