fix(diarization-ui): avoid route conflict for markdown download path

This commit is contained in:
2026-03-21 14:21:10 +01:00
parent 119c8b3f7b
commit 0f5a857b6e

6
app.py
View File

@@ -225,7 +225,7 @@ def library(project_id: Optional[int] = None):
items = "".join(
[
f"<div class='card'><b>#{d['id']}</b> [{d['kind']}] {d['title']}<br><small>{d['project']} · {d['created_at']}</small><br>"
f"<a href='/document/{d['id']}'>Ansehen</a> | <a href='/document/{d['id']}.md'>Download .md</a></div>"
f"<a href='/document/{d['id']}'>Ansehen</a> | <a href='/document/{d['id']}/download.md'>Download .md</a></div>"
for d in docs
]
)
@@ -260,13 +260,13 @@ def view_document(doc_id: int):
body = f"""
<h2>Dokument #{d['id']} {d['title']}</h2>
<p><small>Projekt: {d['project']} · Typ: {d['kind']} · {d['created_at']}</small></p>
<p><a href='/document/{doc_id}.md'>Download .md</a></p>
<p><a href='/document/{doc_id}/download.md'>Download .md</a></p>
<pre>{(d['content_md'] or '').replace('<','&lt;')}</pre>
"""
return layout("Dokument", body)
@app.get("/document/{doc_id}.md", response_class=PlainTextResponse)
@app.get("/document/{doc_id}/download.md", response_class=PlainTextResponse)
def download_md(doc_id: int):
with db() as c:
d = c.execute("SELECT title,content_md FROM documents WHERE id=?", (doc_id,)).fetchone()