Johnyquest7 commited on
Commit
55a4f2f
·
verified ·
1 Parent(s): 1de773f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -10
app.py CHANGED
@@ -42,16 +42,15 @@ def pubmed_search(mesh_terms, email, start_date, end_date):
42
  if not mesh_terms or not email:
43
  return "Please provide MeSH terms and email.", None, None
44
 
45
- # Convert date objects to string format
46
  try:
47
- # If start_date and end_date are strings, parse them first
48
  if isinstance(start_date, str):
49
- start_date = datetime.strptime(start_date, "%Y-%m-%d")
50
  if isinstance(end_date, str):
51
- end_date = datetime.strptime(end_date, "%Y-%m-%d")
52
 
53
- start_date_str = start_date.strftime("%Y-%m-%d")
54
- end_date_str = end_date.strftime("%Y-%m-%d")
55
  except ValueError as e:
56
  return f"Error processing dates: {str(e)}", None, None
57
 
@@ -114,8 +113,8 @@ with gr.Blocks() as app:
114
  )
115
 
116
  with gr.Row():
117
- start_date = gr.DateTime(label="Start Date", value="2025-01-01") # Changed from DateTime to Date
118
- end_date = gr.DateTime(label="End Date", value="2025-01-07") # Changed from DateTime to Date
119
 
120
  email_input = gr.Textbox(
121
  label="Email",
@@ -141,5 +140,4 @@ with gr.Blocks() as app:
141
  outputs=[status_output, markdown_file, text_file]
142
  )
143
 
144
-
145
- app.launch()
 
42
  if not mesh_terms or not email:
43
  return "Please provide MeSH terms and email.", None, None
44
 
45
+ # Ensure time defaults to midnight if not provided
46
  try:
 
47
  if isinstance(start_date, str):
48
+ start_date = datetime.strptime(start_date, "%Y-%m-%d %H:%M:%S")
49
  if isinstance(end_date, str):
50
+ end_date = datetime.strptime(end_date, "%Y-%m-%d %H:%M:%S")
51
 
52
+ start_date_str = start_date.strftime("%Y-%m-%d %H:%M:%S")
53
+ end_date_str = end_date.strftime("%Y-%m-%d %H:%M:%S")
54
  except ValueError as e:
55
  return f"Error processing dates: {str(e)}", None, None
56
 
 
113
  )
114
 
115
  with gr.Row():
116
+ start_date = gr.DateTime(label="Start Date", value="2025-01-01 00:00:00") # Ensure midnight time
117
+ end_date = gr.DateTime(label="End Date", value="2025-01-07 00:00:00") # Ensure midnight time
118
 
119
  email_input = gr.Textbox(
120
  label="Email",
 
140
  outputs=[status_output, markdown_file, text_file]
141
  )
142
 
143
+ app.launch()