albumup commited on
Commit
4f7d7bc
·
verified ·
1 Parent(s): 1e9923c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +273 -45
app.py CHANGED
@@ -74,75 +74,303 @@ async def index():
74
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
75
  <title>File Upload</title>
76
  <style>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  .progress-bar {
78
  width: 100%;
79
- background-color: #f3f3f3;
80
- border-radius: 5px;
81
- margin-top: 10px;
 
 
 
82
  }
 
83
  .progress-bar-inner {
 
 
84
  width: 0%;
85
- height: 30px;
86
- background-color: #4caf50;
87
- border-radius: 5px;
88
- text-align: center;
89
- line-height: 30px;
90
- color: white;
91
  transition: width 0.3s ease;
92
  }
 
93
  .button {
94
  display: inline-block;
95
- padding: 10px 20px;
96
- background-color: #007bff;
97
  color: white;
98
- text-decoration: none;
99
- border-radius: 5px;
100
- margin: 5px;
 
 
 
101
  }
 
102
  .button:hover {
103
- background-color: #0056b3;
104
  }
105
- .private-checkbox {
106
- margin: 10px 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  }
108
  </style>
109
  </head>
110
  <body>
111
- <h1>File Upload & Album Management</h1>
112
- <form action="/album/create" method="post" enctype="multipart/form-data" onsubmit="showProgressBar()">
113
- <input type="text" name="album_name" placeholder="Album Name" required><br><br>
114
- <input type="file" name="files" accept="*/*" multiple required><br><br>
115
- <label class="private-checkbox">
116
- <input type="checkbox" name="is_private"> Make this album private (exclude from search)
117
- </label><br><br>
118
- <div class="progress-bar">
119
- <div class="progress-bar-inner" id="progressBar">0%</div>
120
- </div>
121
- <button type="submit">Create Album</button>
122
- </form>
123
- <h2>Single File Upload</h2>
124
- <a href="https://albumup-up1.hf.space/" class="button">Upload Single File</a>
125
- <h2>Search Albums</h2>
126
- <form action="/search" method="get">
127
- <input type="text" name="query" placeholder="Search by album name..." required>
128
- <button type="submit">Search</button>
129
- </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  <script>
131
  function showProgressBar() {
132
  const progressBar = document.getElementById('progressBar');
133
- progressBar.style.width = '0%';
134
- progressBar.textContent = '0%';
 
 
 
 
 
 
 
 
135
  const interval = setInterval(() => {
136
- const width = parseFloat(progressBar.style.width);
137
- if (width < 90) {
138
- const newWidth = width + 1;
139
- progressBar.style.width = newWidth + '%';
140
- progressBar.textContent = Math.round(newWidth) + '%';
141
- } else {
142
  clearInterval(interval);
143
  }
144
- }, 30); // Update every 30ms for smoother progress
145
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  </script>
147
  </body>
148
  </html>
 
74
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
75
  <title>File Upload</title>
76
  <style>
77
+ body {
78
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
79
+ margin: 0;
80
+ padding: 20px;
81
+ background-color: #f5f5f5;
82
+ color: #333;
83
+ }
84
+
85
+ .container {
86
+ max-width: 800px;
87
+ margin: 0 auto;
88
+ background: white;
89
+ padding: 30px;
90
+ border-radius: 12px;
91
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
92
+ }
93
+
94
+ h1 {
95
+ font-size: 2.5em;
96
+ margin-bottom: 20px;
97
+ color: #007bff;
98
+ }
99
+
100
+ h2 {
101
+ font-size: 1.8em;
102
+ margin-top: 30px;
103
+ margin-bottom: 15px;
104
+ color: #333;
105
+ }
106
+
107
+ .upload-form {
108
+ margin-top: 20px;
109
+ }
110
+
111
+ .form-group {
112
+ margin-bottom: 20px;
113
+ }
114
+
115
+ .form-group label {
116
+ display: block;
117
+ font-weight: 500;
118
+ margin-bottom: 8px;
119
+ }
120
+
121
+ .form-group input[type="text"],
122
+ .form-group input[type="file"] {
123
+ width: 100%;
124
+ padding: 12px;
125
+ border: 2px solid #ddd;
126
+ border-radius: 8px;
127
+ font-size: 1em;
128
+ transition: border-color 0.3s ease;
129
+ }
130
+
131
+ .form-group input[type="text"]:focus,
132
+ .form-group input[type="file"]:focus {
133
+ border-color: #007bff;
134
+ outline: none;
135
+ }
136
+
137
+ .file-input {
138
+ background: #f8f9fa;
139
+ padding: 20px;
140
+ border-radius: 8px;
141
+ border: 2px dashed #ddd;
142
+ text-align: center;
143
+ cursor: pointer;
144
+ transition: background 0.3s ease, border-color 0.3s ease;
145
+ }
146
+
147
+ .file-input:hover {
148
+ background: #e9ecef;
149
+ border-color: #007bff;
150
+ }
151
+
152
+ .file-input.dragover {
153
+ background: #e9ecef;
154
+ border-color: #007bff;
155
+ }
156
+
157
+ .file-input input {
158
+ display: none;
159
+ }
160
+
161
+ .file-input label {
162
+ font-size: 1.1em;
163
+ color: #666;
164
+ cursor: pointer;
165
+ }
166
+
167
+ .private-checkbox {
168
+ display: flex;
169
+ align-items: center;
170
+ gap: 10px;
171
+ margin-top: 20px;
172
+ }
173
+
174
+ .private-checkbox input {
175
+ width: 18px;
176
+ height: 18px;
177
+ cursor: pointer;
178
+ }
179
+
180
+ .private-checkbox label {
181
+ font-size: 1em;
182
+ color: #666;
183
+ }
184
+
185
  .progress-bar {
186
  width: 100%;
187
+ height: 12px;
188
+ background: #e9ecef;
189
+ border-radius: 6px;
190
+ margin-top: 20px;
191
+ overflow: hidden;
192
+ display: none;
193
  }
194
+
195
  .progress-bar-inner {
196
+ height: 100%;
197
+ background: #007bff;
198
  width: 0%;
199
+ border-radius: 6px;
 
 
 
 
 
200
  transition: width 0.3s ease;
201
  }
202
+
203
  .button {
204
  display: inline-block;
205
+ padding: 12px 24px;
206
+ background: #007bff;
207
  color: white;
208
+ border: none;
209
+ border-radius: 8px;
210
+ font-size: 1em;
211
+ cursor: pointer;
212
+ transition: background 0.3s ease;
213
+ margin-top: 20px;
214
  }
215
+
216
  .button:hover {
217
+ background: #0056b3;
218
  }
219
+
220
+ .button:disabled {
221
+ background: #ccc;
222
+ cursor: not-allowed;
223
+ }
224
+
225
+ .upload-status {
226
+ margin-top: 20px;
227
+ font-size: 0.9em;
228
+ color: #666;
229
+ }
230
+
231
+ .search-form {
232
+ margin-top: 30px;
233
+ }
234
+
235
+ .search-form input[type="text"] {
236
+ width: calc(100% - 100px);
237
+ padding: 12px;
238
+ border: 2px solid #ddd;
239
+ border-radius: 8px;
240
+ font-size: 1em;
241
+ transition: border-color 0.3s ease;
242
+ }
243
+
244
+ .search-form input[type="text"]:focus {
245
+ border-color: #007bff;
246
+ outline: none;
247
+ }
248
+
249
+ .search-form button {
250
+ padding: 12px 24px;
251
+ background: #28a745;
252
+ color: white;
253
+ border: none;
254
+ border-radius: 8px;
255
+ font-size: 1em;
256
+ cursor: pointer;
257
+ transition: background 0.3s ease;
258
+ }
259
+
260
+ .search-form button:hover {
261
+ background: #218838;
262
+ }
263
+
264
+ @media (max-width: 768px) {
265
+ .container {
266
+ padding: 20px;
267
+ }
268
+
269
+ h1 {
270
+ font-size: 2em;
271
+ }
272
+
273
+ h2 {
274
+ font-size: 1.5em;
275
+ }
276
+
277
+ .button {
278
+ width: 100%;
279
+ margin-top: 15px;
280
+ }
281
+
282
+ .search-form input[type="text"] {
283
+ width: calc(100% - 90px);
284
+ }
285
  }
286
  </style>
287
  </head>
288
  <body>
289
+ <div class="container">
290
+ <h1>File Upload & Album Management</h1>
291
+
292
+ <form class="upload-form" action="/album/create" method="post" enctype="multipart/form-data" onsubmit="showProgressBar()">
293
+ <div class="form-group">
294
+ <label for="album_name">Album Name</label>
295
+ <input type="text" id="album_name" name="album_name" placeholder="Enter album name" required>
296
+ </div>
297
+
298
+ <div class="form-group">
299
+ <div class="file-input" id="fileInput" ondragover="handleDragOver(event)" ondrop="handleDrop(event)">
300
+ <input type="file" id="files" name="files" multiple required>
301
+ <label for="files">Drag & drop files here or click to upload</label>
302
+ </div>
303
+ </div>
304
+
305
+ <div class="private-checkbox">
306
+ <input type="checkbox" id="is_private" name="is_private">
307
+ <label for="is_private">Make this album private (exclude from search)</label>
308
+ </div>
309
+
310
+ <div class="progress-bar" id="progressBar">
311
+ <div class="progress-bar-inner" id="progressBarInner"></div>
312
+ </div>
313
+
314
+ <button type="submit" class="button" id="uploadButton">Create Album</button>
315
+ <div class="upload-status" id="uploadStatus"></div>
316
+ </form>
317
+
318
+ <h2>Search Albums</h2>
319
+ <form class="search-form" action="/search" method="get">
320
+ <input type="text" name="query" placeholder="Search by album name..." required>
321
+ <button type="submit">Search</button>
322
+ </form>
323
+ </div>
324
+
325
  <script>
326
  function showProgressBar() {
327
  const progressBar = document.getElementById('progressBar');
328
+ const progressBarInner = document.getElementById('progressBarInner');
329
+ const uploadButton = document.getElementById('uploadButton');
330
+ const uploadStatus = document.getElementById('uploadStatus');
331
+
332
+ progressBar.style.display = 'block';
333
+ uploadButton.disabled = true;
334
+ uploadButton.textContent = 'Uploading...';
335
+ uploadStatus.textContent = 'Starting upload...';
336
+
337
+ let progress = 0;
338
  const interval = setInterval(() => {
339
+ progress += 1;
340
+ progressBarInner.style.width = progress + '%';
341
+ if (progress >= 90) {
 
 
 
342
  clearInterval(interval);
343
  }
344
+ }, 30);
345
  }
346
+
347
+ function handleDragOver(event) {
348
+ event.preventDefault();
349
+ const fileInput = document.getElementById('fileInput');
350
+ fileInput.classList.add('dragover');
351
+ }
352
+
353
+ function handleDrop(event) {
354
+ event.preventDefault();
355
+ const fileInput = document.getElementById('fileInput');
356
+ fileInput.classList.remove('dragover');
357
+ const files = event.dataTransfer.files;
358
+ document.getElementById('files').files = files;
359
+ updateFileLabel(files);
360
+ }
361
+
362
+ function updateFileLabel(files) {
363
+ const label = document.querySelector('.file-input label');
364
+ if (files.length > 0) {
365
+ label.textContent = `${files.length} file(s) selected`;
366
+ } else {
367
+ label.textContent = 'Drag & drop files here or click to upload';
368
+ }
369
+ }
370
+
371
+ document.getElementById('files').addEventListener('change', (event) => {
372
+ updateFileLabel(event.target.files);
373
+ });
374
  </script>
375
  </body>
376
  </html>