Merge branch 'feature/recursive-input' into develop
This commit is contained in:
commit
6deefc7ea8
4 changed files with 16 additions and 3 deletions
|
@ -1,4 +1,5 @@
|
||||||
imgdir = "."
|
imgdir = "."
|
||||||
|
recursive = True
|
||||||
refresh = 5
|
refresh = 5
|
||||||
cachedir = "/tmp/webslider"
|
cachedir = "/tmp/webslider"
|
||||||
resolution = (1920, 1080)
|
resolution = (1920, 1080)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
Flask==1.0.2
|
Flask==1.0.2
|
||||||
Pillow==5.3.0
|
Pillow==5.3.0
|
||||||
Click==7.0
|
Click==7.0
|
||||||
|
waitress==1.1.0
|
||||||
|
|
8
server.py
Executable file
8
server.py
Executable file
|
@ -0,0 +1,8 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
from waitress import serve
|
||||||
|
|
||||||
|
import slider
|
||||||
|
|
||||||
|
serve(slider.app, host="0.0.0.0", port=8080)
|
||||||
|
|
|
@ -14,6 +14,7 @@ import config
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
imgdir = Path(config.imgdir).expanduser().resolve()
|
imgdir = Path(config.imgdir).expanduser().resolve()
|
||||||
|
img_glob = "**/*.jpg" if config.recursive else "*.jpg"
|
||||||
cache_resolution = config.resolution
|
cache_resolution = config.resolution
|
||||||
cache_dir = Path(config.cachedir) / ("%sx%s" % cache_resolution)
|
cache_dir = Path(config.cachedir) / ("%sx%s" % cache_resolution)
|
||||||
|
|
||||||
|
@ -25,7 +26,6 @@ def random():
|
||||||
|
|
||||||
@app.route("/random_image/")
|
@app.route("/random_image/")
|
||||||
def random_image():
|
def random_image():
|
||||||
img_glob = "*jpg"
|
|
||||||
last_modified_time, last_modified_file = max(
|
last_modified_time, last_modified_file = max(
|
||||||
(f.stat().st_mtime, f) for f in imgdir.glob(img_glob)
|
(f.stat().st_mtime, f) for f in imgdir.glob(img_glob)
|
||||||
)
|
)
|
||||||
|
@ -36,7 +36,10 @@ def random_image():
|
||||||
images = list(imgdir.glob(img_glob))
|
images = list(imgdir.glob(img_glob))
|
||||||
selected_image = choice(images).relative_to(imgdir)
|
selected_image = choice(images).relative_to(imgdir)
|
||||||
|
|
||||||
return redirect(url_for("image", filename=selected_image) + "?hash=%s" % get_cache_filename(selected_image))
|
return redirect(
|
||||||
|
url_for("image", filename=selected_image)
|
||||||
|
+ "?hash=%s" % get_cache_filename(selected_image)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/img/<path:filename>")
|
@app.route("/img/<path:filename>")
|
||||||
|
@ -77,7 +80,7 @@ def get_cache_filename(filename):
|
||||||
|
|
||||||
|
|
||||||
def pre_cache_images():
|
def pre_cache_images():
|
||||||
for image_file in sorted(imgdir.glob("*.jpg")):
|
for image_file in sorted(imgdir.glob(img_glob)):
|
||||||
create_cache_file(image_file.relative_to(imgdir))
|
create_cache_file(image_file.relative_to(imgdir))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue