|
@@ -4,12 +4,15 @@ This module contains a flask blueprint for db administration stuff
|
|
|
Templates are self-contained in this directory
|
|
|
"""
|
|
|
from __future__ import print_function
|
|
|
+import os
|
|
|
from datetime import datetime, timedelta, time
|
|
|
from collections import defaultdict
|
|
|
+import mimetypes
|
|
|
|
|
|
from flask import (
|
|
|
current_app,
|
|
|
Blueprint,
|
|
|
+ Response,
|
|
|
render_template,
|
|
|
jsonify,
|
|
|
abort,
|
|
@@ -227,3 +230,16 @@ def delete_alarm(alarmid):
|
|
|
return jsonify(dict(deleted=alarmid))
|
|
|
flash("Evento %d `%s` cancellato" % (alarmid, alarm["nick"]))
|
|
|
return redirect(url_for("db.events_list"))
|
|
|
+
|
|
|
+
|
|
|
+@db.route("/quick/<path:relpath>")
|
|
|
+def static_custom(relpath):
|
|
|
+ basepath = get_conf()['EXTRA_STATIC_PATH']
|
|
|
+ if not basepath:
|
|
|
+ abort(405)
|
|
|
+ fpath = os.path.join(basepath, relpath)
|
|
|
+ print(basepath, fpath)
|
|
|
+ if not os.path.isfile(fpath):
|
|
|
+ abort(404, "File non trovato")
|
|
|
+ mime, _encoding = mimetypes.guess_type(fpath)
|
|
|
+ return Response(open(fpath, 'rb').read(), mimetype=mime)
|