dockerize and fix relative URLs for /slideshow path prefix

This commit is contained in:
Johannes
2026-05-03 21:11:52 +02:00
parent 0428784789
commit 01190086a5
4 changed files with 29 additions and 6 deletions

8
Dockerfile Normal file
View File

@@ -0,0 +1,8 @@
FROM python:3.12-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
RUN mkdir -p Pictures
EXPOSE 5000
CMD ["python", "Slideshow.py"]

View File

@@ -19,7 +19,7 @@ downloads = {}
def slideshow():
raw_query = request.args.get('tags', '').strip()
results = search_images(raw_query)
image_urls = [f'/pictures/{r["filename"]}' for r in results]
image_urls = [f'pictures/{r["filename"]}' for r in results]
post_urls = [r['post_url'] for r in results]
tags_list = [r['tags'].split() for r in results]
active_tags = raw_query.split() if raw_query else []
@@ -90,4 +90,4 @@ def download_progress(job_id):
if __name__ == '__main__':
app.run(debug=True)
app.run(host='0.0.0.0', debug=False)

15
docker-compose.yml Normal file
View File

@@ -0,0 +1,15 @@
services:
diashow:
build: .
container_name: diashow
restart: unless-stopped
env_file: .env
volumes:
- ./Pictures:/app/Pictures
- ./booru.db:/app/booru.db
networks:
- caddy
networks:
caddy:
external: true

View File

@@ -46,7 +46,7 @@
<body>
<h1>Booru Slideshow</h1>
<form id="tag-form" method="get" action="/">
<form id="tag-form" method="get" action="">
<input type="text" name="tags" id="tag-input" placeholder="e.g. swimsuit blonde_hair" value="{{ tag_query }}" />
<button type="submit">Search</button>
<select name="_site" id="site-select">
@@ -94,7 +94,7 @@
const site = document.getElementById('site-select').value;
const form = document.createElement('form');
form.method = 'post';
form.action = '/download';
form.action = 'download';
[['tags', tags], ['site', site]].forEach(([k, v]) => {
const inp = document.createElement('input');
inp.type = 'hidden'; inp.name = k; inp.value = v;
@@ -110,14 +110,14 @@
const bar = document.getElementById('progress-bar');
const label = document.getElementById('progress-label');
box.style.display = 'block';
const es = new EventSource(`/download/progress/${job_id}`);
const es = new EventSource(`download/progress/${job_id}`);
es.onmessage = (e) => {
const d = JSON.parse(e.data);
if (d.error) { label.textContent = 'Error: ' + d.error; es.close(); return; }
const pct = d.total > 0 ? Math.round(d.done / d.total * 100) : 0;
bar.style.width = pct + '%';
if (d.finished) {
label.innerHTML = `Done! ${d.done} images. <a href="/?tags={{ tag_query }}" style="color:#8b8">Refresh</a>`;
label.innerHTML = `Done! ${d.done} images. <a href="?tags={{ tag_query }}" style="color:#8b8">Refresh</a>`;
es.close();
} else {
label.textContent = d.total > 0 ? `${d.done} / ${d.total}` : 'Fetching post list...';