backend: add webp mimetype
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
2bfce259e4
commit
d9a5bcdd54
|
@ -3,7 +3,7 @@ from backend import CalibreDB
|
|||
from flask import Flask, jsonify, send_from_directory, send_file, render_template, request
|
||||
from flask_cors import CORS
|
||||
from werkzeug.routing import BaseConverter
|
||||
import mimetypes
|
||||
from mimetypes import types_map as mimetypes
|
||||
import os
|
||||
|
||||
|
||||
|
@ -14,6 +14,8 @@ def send_from_cwd(filename):
|
|||
app = Flask(__name__, static_folder='frontend/dist/static', template_folder='frontend/dist')
|
||||
CORS(app)
|
||||
|
||||
mimetypes['.webp'] = 'image/webp'
|
||||
|
||||
db = CalibreDB()
|
||||
|
||||
# kind of redundant, but avoids returning 200 if page does not exist
|
||||
|
@ -64,7 +66,7 @@ def get_volume_info(volume_id):
|
|||
@app.route('/api/volume/<int:volume_id>/page/<int:page_number>')
|
||||
def get_volume_page(volume_id, page_number):
|
||||
page = db.get_volume_page(volume_id, page_number)
|
||||
mimetype = mimetypes.types_map[page['extension']]
|
||||
mimetype = mimetypes[page['extension']]
|
||||
return send_file(page['data'], mimetype=mimetype)
|
||||
|
||||
|
||||
|
|
Reference in a new issue