list of uploaded files
This commit is contained in:
parent
15c890b4cf
commit
7466814824
2 changed files with 40 additions and 3 deletions
|
@ -117,6 +117,17 @@ async def upload(
|
|||
raise
|
||||
|
||||
|
||||
@app.post("/list")
|
||||
def list():
|
||||
return "lista file"
|
||||
@app.get("/list")
|
||||
def list(request: Request):
|
||||
files = []
|
||||
with session_pool() as conn:
|
||||
query = conn.query(database.Original).order_by(-database.Original.id).limit(100)
|
||||
for original in query:
|
||||
files.append(original.__dict__)
|
||||
data = {"files": files}
|
||||
|
||||
if "application/json" in request.headers.get("accept", ""):
|
||||
return data
|
||||
return templates.TemplateResponse(
|
||||
name="list.html", request=request, context=data
|
||||
)
|
||||
|
|
26
caricari/templates/list.html
Normal file
26
caricari/templates/list.html
Normal file
|
@ -0,0 +1,26 @@
|
|||
<html>
|
||||
<head>
|
||||
<style>
|
||||
.filelist td.name {
|
||||
font-family: monospace;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table class="filelist" width="100%">
|
||||
<thead>
|
||||
<th>Name</th>
|
||||
<th>Size</th>
|
||||
<th></th>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for orig in files %}
|
||||
<tr>
|
||||
<td class="name">{{orig.name}}</td>
|
||||
<td class="size">{{orig.size}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue