Spaces:
Build error
Build error
Update app.py
Browse files
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
|
| 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()
|