tx3bas commited on
Commit
c25e9d3
·
verified ·
1 Parent(s): 86c6d07

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -19,8 +19,12 @@ def wayback(website):
19
  if response.status_code == 200:
20
  content = json.loads(response.text)
21
  if len(content) > 1:
 
 
 
 
22
  results = ["<table><tr><th>Fecha</th><th>URL</th></tr>"]
23
- for row in content[1:]:
24
  date, page, status = [row[i] for i in [1, 2, 4]]
25
  formatted_date = datetime.strptime(date, '%Y%m%d%H%M%S').strftime('%d/%m/%Y')
26
  formatted_wayback_url = f"https://web.archive.org/web/{date}/{page}"
@@ -47,6 +51,7 @@ def wayback(website):
47
  return f"<p>😭 Error: {e}</p>"
48
 
49
  return '<p>😭 Error: No se encontraron datos archivados para esta URL.</p>'
 
50
  def archive_now(website):
51
  if not website:
52
  return "Por favor, introduce una URL válida."
@@ -83,4 +88,4 @@ archive_interface = gr.Interface(
83
  iface = gr.TabbedInterface([wayback_interface, archive_interface], ["Buscar Instantáneas", "Archivar URL"])
84
 
85
  # Lanzar la aplicación
86
- iface.launch()
 
19
  if response.status_code == 200:
20
  content = json.loads(response.text)
21
  if len(content) > 1:
22
+ # Ordenar los resultados por fecha de manera descendente
23
+ sorted_content = sorted(content[1:], key=lambda x: x[1], reverse=True)
24
+
25
+ # Crear la tabla HTML
26
  results = ["<table><tr><th>Fecha</th><th>URL</th></tr>"]
27
+ for row in sorted_content:
28
  date, page, status = [row[i] for i in [1, 2, 4]]
29
  formatted_date = datetime.strptime(date, '%Y%m%d%H%M%S').strftime('%d/%m/%Y')
30
  formatted_wayback_url = f"https://web.archive.org/web/{date}/{page}"
 
51
  return f"<p>😭 Error: {e}</p>"
52
 
53
  return '<p>😭 Error: No se encontraron datos archivados para esta URL.</p>'
54
+
55
  def archive_now(website):
56
  if not website:
57
  return "Por favor, introduce una URL válida."
 
88
  iface = gr.TabbedInterface([wayback_interface, archive_interface], ["Buscar Instantáneas", "Archivar URL"])
89
 
90
  # Lanzar la aplicación
91
+ iface.launch()