fix(diarization-ui): avoid route conflict for markdown download path
This commit is contained in:
6
app.py
6
app.py
@@ -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('<','<')}</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()
|
||||
|
||||
Reference in New Issue
Block a user