File size: 2,129 Bytes
81d8c42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
{% extends "base.html" %}
{% block title %}Dashboard β€” Task 1{% endblock %}

{% block content %}

<!-- Upload Card -->
<div class="card" style="margin-bottom:2rem;">
  <h2>Upload Files</h2>
  <p class="subtitle">Accepted formats: PDF, PNG, JPEG  (max 2 files at a time)</p>

  <form method="POST" action="/upload" enctype="multipart/form-data" id="upload-form">
    <div class="file-inputs">
      <div class="file-input-wrapper">
        <span>πŸ“„ File 1</span>
        <input type="file" name="file1" accept=".pdf,.png,.jpg,.jpeg" required>
      </div>
    </div>
    <button type="submit" class="btn btn-primary" style="margin-top:1.2rem;">⬆ Upload</button>
  </form>
</div>

<!-- File List Card -->
<div class="card">
  <h2>Your Files</h2>
  <p class="subtitle">{{ files | length }} file{{ 's' if files | length != 1 else '' }} stored</p>

  {% if files %}
  <div class="table-wrap">
    <table>
      <thead>
        <tr>
          <th>#</th>
          <th>Filename</th>
          <th>Type</th>
          <th>Uploaded</th>
          <th>Actions</th>
        </tr>
      </thead>
      <tbody>
        {% for f in files %}
        <tr>
          <td>{{ loop.index }}</td>
          <td>{{ f.filename }}</td>
          <td>
            {% set ext = f.file_type | replace('.','') %}
            <span class="badge badge-{{ ext }}">{{ ext | upper }}</span>
          </td>
          <td>{{ f.upload_timestamp.strftime('%d %b %Y, %H:%M') if f.upload_timestamp else 'β€”' }}</td>
          <td class="actions">
            <a href="/download/{{ f.id }}" class="btn btn-outline btn-sm">⬇ Download</a>
            <form action="/delete/{{ f.id }}" method="get" style="display:inline;"
                  onsubmit="return confirm('Delete this file?')">
              <button type="submit" class="btn btn-danger btn-sm">πŸ—‘ Delete</button>
            </form>
          </td>
        </tr>
        {% endfor %}
      </tbody>
    </table>
  </div>
  {% else %}
  <div class="empty-state">
    <div class="icon">πŸ“‚</div>
    <p>No files yet β€” upload your first file above!</p>
  </div>
  {% endif %}
</div>

{% endblock %}