summaryrefslogtreecommitdiff
path: root/flask-mediabrowser
blob: 584d7bb95835730984260d7b600744288a26aa73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env python3.4
from flask import Flask
from werkzeug.contrib.cache import FileSystemCache

import mediabrowser

import os
import tempfile
import logging
from argparse import ArgumentParser


logging.basicConfig(level=logging.INFO)


if __name__ == "__main__":
    parser = ArgumentParser(description="Flask Mediabrowser")
    parser.add_argument("--root", metavar="DIR", required=True,
        help="Media collection root directory")

    args = parser.parse_args()

    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))

    app.run(debug=True)