ninooo96 commited on
Commit
158c788
·
1 Parent(s): 75ae8d8
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -96,7 +96,8 @@ details[open] summary::before { content: "✅ "; }
96
  LOADING_HTML = """
97
  <div style="display: flex; justify-content: center; align-items: center; height: 100px; width: 100%; flex-direction: column;">
98
  <div style="border: 4px solid #374151; border-top: 4px solid #3b82f6; border-radius: 50%; width: 30px; height: 30px; animation: spin 1s linear infinite;"></div>
99
- <p style="margin-top: 10px; color: #9ca3af; font-size: 0.9em;">{}</p> </div>
 
100
  <style>@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }</style>
101
  """
102
 
@@ -180,8 +181,8 @@ def update_ui_labels(new_lang):
180
  ]
181
 
182
  def search_logic(query, max_res, lang_pref):
183
- loading_html_dynamic = LOADING_HTML.format(L("search_loading_message", lang_pref))
184
- yield gr.update(visible=True), gr.update(visible=False)
185
  if not query:
186
  yield gr.update(visible=False), L("error_no_query", lang_pref)
187
  return
@@ -196,8 +197,8 @@ def search_logic(query, max_res, lang_pref):
196
  yield gr.update(visible=False), f"Errore: {e}"
197
 
198
  def find_logic(title):
199
- loading_html_dynamic = LOADING_HTML.format(L("search_loading_message", "en"))
200
- yield gr.update(visible=True), gr.update(visible=False), [], gr.update(visible=False)
201
  conn = get_turso_conn()
202
  rows = conn.execute(f"SELECT id, title, author, year FROM books WHERE title LIKE '%{title}%' LIMIT 10").fetchall()
203
  conn.close()
@@ -223,7 +224,7 @@ def clean_tab1(): return gr.update(value=""), gr.update(value="", visible=False)
223
  def clean_tab2(): return gr.update(value=""), gr.update(visible=False), gr.update(value="", visible=False)
224
 
225
  # --- UI ---
226
- with gr.Blocks(theme=gr.themes.Ocean(), css=GLOBAL_CSS, js=JS_FORCE_DARK) as demo:
227
  app_title_md = gr.Markdown(f"# {L('app_title')}")
228
  books_state = gr.State([])
229
 
@@ -241,7 +242,7 @@ with gr.Blocks(theme=gr.themes.Ocean(), css=GLOBAL_CSS, js=JS_FORCE_DARK) as dem
241
  with gr.Row():
242
  txt_tit = gr.Textbox(placeholder=L("title_search_placeholder"), show_label=False, scale=4)
243
  btn_find = gr.Button(L("title_search_button"), scale=1)
244
- loader_list = gr.HTML(value=LOADING_HTML.format(L("search_loading_message")), visible=False)
245
 
246
  # --- CORREZIONE TABELLA QUI SOTTO ---
247
  dataset = gr.Dataset(
@@ -253,7 +254,7 @@ with gr.Blocks(theme=gr.themes.Ocean(), css=GLOBAL_CSS, js=JS_FORCE_DARK) as dem
253
  type="index"
254
  )
255
 
256
- loader = gr.HTML(value=LOADING_HTML.format(L("search_loading_message")), visible=False)
257
  results = gr.HTML(label=L("results_label"), visible=True)
258
 
259
  # EVENTI
@@ -285,4 +286,4 @@ with gr.Blocks(theme=gr.themes.Ocean(), css=GLOBAL_CSS, js=JS_FORCE_DARK) as dem
285
  t1.select(clean_tab2, None, [txt_tit, dataset, results])
286
  t2.select(clean_tab1, None, [txt_in, results])
287
 
288
- demo.launch()
 
96
  LOADING_HTML = """
97
  <div style="display: flex; justify-content: center; align-items: center; height: 100px; width: 100%; flex-direction: column;">
98
  <div style="border: 4px solid #374151; border-top: 4px solid #3b82f6; border-radius: 50%; width: 30px; height: 30px; animation: spin 1s linear infinite;"></div>
99
+ <p style="margin-top: 10px; color: #9ca3af; font-size: 0.9em;">__LOADING_TEXT__</p>
100
+ </div>
101
  <style>@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }</style>
102
  """
103
 
 
181
  ]
182
 
183
  def search_logic(query, max_res, lang_pref):
184
+ loading_html_dynamic = LOADING_HTML.replace("__LOADING_TEXT__", L("search_loading_message", lang_pref))
185
+ yield gr.update(loading_html_dynamic, visible=True), gr.update(visible=False)
186
  if not query:
187
  yield gr.update(visible=False), L("error_no_query", lang_pref)
188
  return
 
197
  yield gr.update(visible=False), f"Errore: {e}"
198
 
199
  def find_logic(title):
200
+ loading_html_dynamic = LOADING_HTML.replace("__LOADING_TEXT__", L("search_loading_message", "en"))
201
+ yield gr.update(loading_html_dynamic, visible=True), gr.update(visible=False), [], gr.update(visible=False)
202
  conn = get_turso_conn()
203
  rows = conn.execute(f"SELECT id, title, author, year FROM books WHERE title LIKE '%{title}%' LIMIT 10").fetchall()
204
  conn.close()
 
224
  def clean_tab2(): return gr.update(value=""), gr.update(visible=False), gr.update(value="", visible=False)
225
 
226
  # --- UI ---
227
+ with gr.Blocks(theme=gr.themes.Ocean()) as demo:
228
  app_title_md = gr.Markdown(f"# {L('app_title')}")
229
  books_state = gr.State([])
230
 
 
242
  with gr.Row():
243
  txt_tit = gr.Textbox(placeholder=L("title_search_placeholder"), show_label=False, scale=4)
244
  btn_find = gr.Button(L("title_search_button"), scale=1)
245
+ loader_list = gr.HTML(value=LOADING_HTML.replace("__LOADING_TEXT__", L("search_loading_message")), visible=False)
246
 
247
  # --- CORREZIONE TABELLA QUI SOTTO ---
248
  dataset = gr.Dataset(
 
254
  type="index"
255
  )
256
 
257
+ loader = gr.HTML(value=LOADING_HTML.replace("__LOADING_TEXT__", L("search_loading_message")), visible=False)
258
  results = gr.HTML(label=L("results_label"), visible=True)
259
 
260
  # EVENTI
 
286
  t1.select(clean_tab2, None, [txt_tit, dataset, results])
287
  t2.select(clean_tab1, None, [txt_in, results])
288
 
289
+ demo.launch(css=GLOBAL_CSS, js=JS_FORCE_DARK)