MK-316 commited on
Commit
5976c88
β€’
1 Parent(s): a2ff245

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -23,14 +23,17 @@ def search_years(search_by_year, search_by_keywords, query):
23
  else:
24
  return "Please select exactly one search mode."
25
 
26
- # Function to return an HTML image tag with the image URL
 
27
  def get_image_html(year):
28
  match = df[df['YEAR'] == year]
29
  if not match.empty:
30
  image_url = match.iloc[0]['LINK']
31
- return f"<img src='{image_url}' width='800'/>"
 
 
32
  else:
33
- return "No image found for this year."
34
 
35
  # Create Gradio Blocks interface
36
  with gr.Blocks() as app:
@@ -55,7 +58,7 @@ with gr.Blocks() as app:
55
  gr.Markdown("## ❄️ [2] Display a Specific Exam Question Requested")
56
  with gr.Row():
57
  year_input = gr.Textbox(label="Type a file name among the result items: e.g., Year_item_part(a,b)", placeholder="Enter Year like '2024_01'")
58
- submit_button = gr.Button("Show me the exam question") # Added submit button
59
  image_output = gr.HTML()
60
 
61
  # Define action for the submit button
 
23
  else:
24
  return "Please select exactly one search mode."
25
 
26
+
27
+ # Modified function to return keywords above the HTML image tag
28
  def get_image_html(year):
29
  match = df[df['YEAR'] == year]
30
  if not match.empty:
31
  image_url = match.iloc[0]['LINK']
32
+ keywords = match.iloc[0]['KEYWORDS']
33
+ # Place keywords above the image
34
+ return f"<b>🌷 Keywords:</b> πŸ”‘ {keywords}<br><img src='{image_url}' width='800'/>"
35
  else:
36
+ return "No keywords found for this year.", "No image found for this year."
37
 
38
  # Create Gradio Blocks interface
39
  with gr.Blocks() as app:
 
58
  gr.Markdown("## ❄️ [2] Display a Specific Exam Question Requested")
59
  with gr.Row():
60
  year_input = gr.Textbox(label="Type a file name among the result items: e.g., Year_item_part(a,b)", placeholder="Enter Year like '2024_01'")
61
+ submit_button = gr.Button("Show me the exam question") # Updated button text
62
  image_output = gr.HTML()
63
 
64
  # Define action for the submit button