From 478b2feb875e4ef5a458531c0d24f0b2117f5490 Mon Sep 17 00:00:00 2001 From: Yves Fischer Date: Sat, 2 Jan 2016 15:05:53 +0100 Subject: better thumbs, better caching (with filesystem) --- flask-mediabrowser | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'flask-mediabrowser') diff --git a/flask-mediabrowser b/flask-mediabrowser index d1c0f8a..584d7bb 100755 --- a/flask-mediabrowser +++ b/flask-mediabrowser @@ -1,10 +1,11 @@ #!/usr/bin/env python3.4 from flask import Flask -from werkzeug.contrib.cache import SimpleCache +from werkzeug.contrib.cache import FileSystemCache import mediabrowser import os +import tempfile import logging from argparse import ArgumentParser @@ -19,7 +20,12 @@ if __name__ == "__main__": args = parser.parse_args() - cache = SimpleCache(threshold=5000, default_timeout=60*60*5) + cache_dir = os.path.join(tempfile.gettempdir(), + "mediabrowser-{}".format(os.geteuid())) + if not os.path.exists(cache_dir): + os.makedirs(cache_dir) + # default_timeout=0 doesn't work with FileSystemCache + cache = FileSystemCache(cache_dir, default_timeout=9999999999, threshold=5000) app = Flask("mediabrowser-demo") app.register_blueprint(mediabrowser.build(args.root, cache)) -- cgit v1.2.1