seawolf2357 commited on
Commit
c3b008e
Β·
verified Β·
1 Parent(s): 84739ea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -17
app.py CHANGED
@@ -261,7 +261,7 @@ if __name__ == '__main__':
261
 
262
  .grid-container {
263
  display: grid;
264
- grid-template-columns: repeat(auto-fill, minmax(600px, 1fr));
265
  gap: 1.5rem;
266
  }
267
 
@@ -269,28 +269,40 @@ if __name__ == '__main__':
269
  background-color: #ffffff;
270
  border-radius: 8px;
271
  overflow: hidden;
272
- box-shadow: 0 2px 10px rgba(0,0,0,0.1);
273
  display: flex;
274
  flex-direction: column;
 
275
  }
276
 
277
  .grid-header {
278
- padding: 1rem;
279
  border-bottom: 1px solid #eee;
280
  background-color: #f9f9f9;
 
 
 
281
  }
282
 
283
  .grid-header h3 {
284
  margin: 0;
285
  padding: 0;
286
- font-size: 1.2rem;
287
  color: #333;
 
 
 
 
 
 
 
 
 
288
  }
289
 
290
  .grid-content {
291
  flex: 1;
292
  position: relative;
293
- height: 500px;
294
  overflow: hidden;
295
  }
296
 
@@ -379,26 +391,26 @@ if __name__ == '__main__':
379
  <div class="header">
380
  <div class="user-controls">
381
  <div>
382
- <span>Huggingface Account: </span>
383
- <span id="currentUser">Not logged in</span>
384
  </div>
385
 
386
  <div id="loginSection" class="login-section">
387
- <input type="password" id="tokenInput" placeholder="Enter Huggingface API Token" />
388
- <button id="loginButton">Authenticate</button>
389
  <div class="token-help">
390
- You can generate an API token on the <a href="https://huggingface.co/settings/tokens" target="_blank">Huggingface tokens page</a>.
391
  </div>
392
  </div>
393
 
394
  <div id="loggedInSection" class="logged-in-section">
395
- <button id="logoutButton" class="logout">Logout</button>
396
  </div>
397
  </div>
398
  </div>
399
 
400
  <div class="filter-controls">
401
- <input type="text" id="searchInput" placeholder="Search by URL or title" />
402
  </div>
403
 
404
  <div id="statusMessage" class="status-message"></div>
@@ -534,7 +546,7 @@ if __name__ == '__main__':
534
  if (data.success) {
535
  state.username = null;
536
 
537
- elements.currentUser.textContent = 'Not logged in';
538
  elements.tokenInput.value = '';
539
  elements.loginSection.style.display = 'block';
540
  elements.loggedInSection.style.display = 'none';
@@ -577,7 +589,7 @@ if __name__ == '__main__':
577
 
578
  if (!urls || urls.length === 0) {
579
  const noResultsMsg = document.createElement('p');
580
- noResultsMsg.textContent = 'No URLs to display.';
581
  noResultsMsg.style.padding = '1rem';
582
  noResultsMsg.style.fontStyle = 'italic';
583
  elements.gridContainer.appendChild(noResultsMsg);
@@ -591,7 +603,7 @@ if __name__ == '__main__':
591
  const gridItem = document.createElement('div');
592
  gridItem.className = 'grid-item';
593
 
594
- // Header with title
595
  const header = document.createElement('div');
596
  header.className = 'grid-header';
597
 
@@ -599,6 +611,13 @@ if __name__ == '__main__':
599
  titleEl.textContent = title;
600
  header.appendChild(titleEl);
601
 
 
 
 
 
 
 
 
602
  // Add header to grid item
603
  gridItem.appendChild(header);
604
 
@@ -606,10 +625,13 @@ if __name__ == '__main__':
606
  const content = document.createElement('div');
607
  content.className = 'grid-content';
608
 
 
609
  const iframe = document.createElement('iframe');
610
  iframe.src = url;
611
  iframe.title = title;
612
- iframe.loading = 'lazy'; // Lazy load iframes
 
 
613
 
614
  content.appendChild(iframe);
615
 
@@ -650,4 +672,4 @@ if __name__ == '__main__':
650
  ''')
651
 
652
  # Use port 7860 for Huggingface Spaces
653
- app.run(host='0.0.0.0', port=7860)
 
261
 
262
  .grid-container {
263
  display: grid;
264
+ grid-template-columns: repeat(auto-fill, minmax(500px, 1fr));
265
  gap: 1.5rem;
266
  }
267
 
 
269
  background-color: #ffffff;
270
  border-radius: 8px;
271
  overflow: hidden;
272
+ box-shadow: 0 4px 15px rgba(0,0,0,0.1);
273
  display: flex;
274
  flex-direction: column;
275
+ height: 600px;
276
  }
277
 
278
  .grid-header {
279
+ padding: 0.8rem;
280
  border-bottom: 1px solid #eee;
281
  background-color: #f9f9f9;
282
+ display: flex;
283
+ justify-content: space-between;
284
+ align-items: center;
285
  }
286
 
287
  .grid-header h3 {
288
  margin: 0;
289
  padding: 0;
290
+ font-size: 1.1rem;
291
  color: #333;
292
+ white-space: nowrap;
293
+ overflow: hidden;
294
+ text-overflow: ellipsis;
295
+ }
296
+
297
+ .open-link {
298
+ color: #4CAF50;
299
+ text-decoration: none;
300
+ font-size: 0.9rem;
301
  }
302
 
303
  .grid-content {
304
  flex: 1;
305
  position: relative;
 
306
  overflow: hidden;
307
  }
308
 
 
391
  <div class="header">
392
  <div class="user-controls">
393
  <div>
394
+ <span>ν—ˆκΉ…νŽ˜μ΄μŠ€ 계정: </span>
395
+ <span id="currentUser">λ‘œκ·ΈμΈλ˜μ§€ μ•ŠμŒ</span>
396
  </div>
397
 
398
  <div id="loginSection" class="login-section">
399
+ <input type="password" id="tokenInput" placeholder="ν—ˆκΉ…νŽ˜μ΄μŠ€ API 토큰 μž…λ ₯" />
400
+ <button id="loginButton">μΈμ¦ν•˜κΈ°</button>
401
  <div class="token-help">
402
+ API 토큰은 <a href="https://huggingface.co/settings/tokens" target="_blank">ν—ˆκΉ…νŽ˜μ΄μŠ€ 토큰 νŽ˜μ΄μ§€</a>μ—μ„œ 생성할 수 μžˆμŠ΅λ‹ˆλ‹€.
403
  </div>
404
  </div>
405
 
406
  <div id="loggedInSection" class="logged-in-section">
407
+ <button id="logoutButton" class="logout">λ‘œκ·Έμ•„μ›ƒ</button>
408
  </div>
409
  </div>
410
  </div>
411
 
412
  <div class="filter-controls">
413
+ <input type="text" id="searchInput" placeholder="URL λ˜λŠ” 제λͺ©μœΌλ‘œ 검색" />
414
  </div>
415
 
416
  <div id="statusMessage" class="status-message"></div>
 
546
  if (data.success) {
547
  state.username = null;
548
 
549
+ elements.currentUser.textContent = 'λ‘œκ·ΈμΈλ˜μ§€ μ•ŠμŒ';
550
  elements.tokenInput.value = '';
551
  elements.loginSection.style.display = 'block';
552
  elements.loggedInSection.style.display = 'none';
 
589
 
590
  if (!urls || urls.length === 0) {
591
  const noResultsMsg = document.createElement('p');
592
+ noResultsMsg.textContent = 'ν‘œμ‹œν•  URL이 μ—†μŠ΅λ‹ˆλ‹€.';
593
  noResultsMsg.style.padding = '1rem';
594
  noResultsMsg.style.fontStyle = 'italic';
595
  elements.gridContainer.appendChild(noResultsMsg);
 
603
  const gridItem = document.createElement('div');
604
  gridItem.className = 'grid-item';
605
 
606
+ // Header with title and link
607
  const header = document.createElement('div');
608
  header.className = 'grid-header';
609
 
 
611
  titleEl.textContent = title;
612
  header.appendChild(titleEl);
613
 
614
+ const linkEl = document.createElement('a');
615
+ linkEl.href = url;
616
+ linkEl.target = '_blank';
617
+ linkEl.className = 'open-link';
618
+ linkEl.textContent = 'μƒˆ μ°½μ—μ„œ μ—΄κΈ°';
619
+ header.appendChild(linkEl);
620
+
621
  // Add header to grid item
622
  gridItem.appendChild(header);
623
 
 
625
  const content = document.createElement('div');
626
  content.className = 'grid-content';
627
 
628
+ // Create iframe to display the actual content
629
  const iframe = document.createElement('iframe');
630
  iframe.src = url;
631
  iframe.title = title;
632
+ iframe.sandbox = 'allow-same-origin allow-scripts allow-popups allow-forms';
633
+ iframe.allow = 'accelerometer; camera; encrypted-media; geolocation; gyroscope; microphone; midi';
634
+ iframe.loading = 'lazy'; // Lazy load iframes for better performance
635
 
636
  content.appendChild(iframe);
637
 
 
672
  ''')
673
 
674
  # Use port 7860 for Huggingface Spaces
675
+ app.run(host='0.0.0.0', port=7860)