Krixter commited on
Commit
eb30235
ยท
verified ยท
1 Parent(s): f3f3a0c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -42,8 +42,14 @@ def list_files():
42
 
43
  df = pd.DataFrame(data)
44
  if not df.empty:
45
- # Convert 'Last Modified' to datetime for accurate chronological sorting
46
- df["Last Modified"] = pd.to_datetime(df["Last Modified"]).dt.tz_localize(None)
 
 
 
 
 
 
47
 
48
  # Default sort by File Name (alphabetical)
49
  df = df.sort_values(by="File Name", ascending=True)
@@ -79,7 +85,8 @@ def download_file(filename):
79
  return None
80
 
81
  # --- UI LAYOUT ---
82
- with gr.Blocks(theme=gr.themes.Soft(primary_hue="indigo")) as app:
 
83
  gr.Markdown("# ๐Ÿ—„๏ธ AudioNovel Bucket Explorer")
84
  gr.Markdown("View, sort, and download your processed audio files. **Click the column headers below to sort by Name, Date, or Size.**")
85
 
@@ -113,4 +120,5 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="indigo")) as app:
113
  app.load(fn=list_files, inputs=[], outputs=[file_table, file_dropdown])
114
 
115
  if __name__ == "__main__":
116
- app.launch()
 
 
42
 
43
  df = pd.DataFrame(data)
44
  if not df.empty:
45
+ # Safely convert to datetime using errors='coerce' to turn "Unknown" into NaT (Not a Time)
46
+ dt_col = pd.to_datetime(df["Last Modified"], errors='coerce')
47
+
48
+ # Remove timezone info for clean sorting/display
49
+ dt_col = dt_col.dt.tz_localize(None)
50
+
51
+ # Convert back to a clean string format, replacing NaT back with "Unknown" for the UI
52
+ df["Last Modified"] = dt_col.dt.strftime('%Y-%m-%d %H:%M:%S').fillna("Unknown")
53
 
54
  # Default sort by File Name (alphabetical)
55
  df = df.sort_values(by="File Name", ascending=True)
 
85
  return None
86
 
87
  # --- UI LAYOUT ---
88
+ # Theme moved from here to the launch command at the bottom
89
+ with gr.Blocks() as app:
90
  gr.Markdown("# ๐Ÿ—„๏ธ AudioNovel Bucket Explorer")
91
  gr.Markdown("View, sort, and download your processed audio files. **Click the column headers below to sort by Name, Date, or Size.**")
92
 
 
120
  app.load(fn=list_files, inputs=[], outputs=[file_table, file_dropdown])
121
 
122
  if __name__ == "__main__":
123
+ # Theme is applied here now to avoid the Gradio 6.0 warning
124
+ app.launch(theme=gr.themes.Soft(primary_hue="indigo"))