Spaces:
Running
Running
Johnyquest7
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
from Bio import Entrez
|
3 |
-
from datetime import datetime
|
4 |
import os
|
5 |
|
6 |
# Function to fetch PubMed articles
|
@@ -38,21 +38,16 @@ def compile_summaries(records):
|
|
38 |
return content
|
39 |
|
40 |
# Main function for the Gradio interface
|
41 |
-
def pubmed_search(mesh_terms, email
|
42 |
if not mesh_terms or not email:
|
43 |
return "Please provide MeSH terms and email.", None, None
|
44 |
|
45 |
-
#
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
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 |
|
57 |
# Join MeSH terms for query
|
58 |
query = " AND ".join([f'"{term}"[MeSH Terms]' for term in mesh_terms.split(",")])
|
@@ -112,10 +107,6 @@ with gr.Blocks() as app:
|
|
112 |
lines=2
|
113 |
)
|
114 |
|
115 |
-
with gr.Row():
|
116 |
-
start_date = gr.DateTime(label="Start Date", value="2025-01-01 00:00:00")
|
117 |
-
end_date = gr.DateTime(label="End Date", value="2025-01-07 00:00:00")
|
118 |
-
|
119 |
email_input = gr.Textbox(
|
120 |
label="Email",
|
121 |
placeholder="Your email (required by PubMed API)",
|
@@ -136,7 +127,7 @@ with gr.Blocks() as app:
|
|
136 |
|
137 |
search_button.click(
|
138 |
fn=pubmed_search,
|
139 |
-
inputs=[mesh_terms_box, email_input
|
140 |
outputs=[status_output, markdown_file, text_file]
|
141 |
)
|
142 |
|
|
|
1 |
import gradio as gr
|
2 |
from Bio import Entrez
|
3 |
+
from datetime import datetime, timedelta
|
4 |
import os
|
5 |
|
6 |
# Function to fetch PubMed articles
|
|
|
38 |
return content
|
39 |
|
40 |
# Main function for the Gradio interface
|
41 |
+
def pubmed_search(mesh_terms, email):
|
42 |
if not mesh_terms or not email:
|
43 |
return "Please provide MeSH terms and email.", None, None
|
44 |
|
45 |
+
# Set default dates
|
46 |
+
end_date = datetime.now()
|
47 |
+
start_date = end_date - timedelta(days=7)
|
48 |
+
|
49 |
+
start_date_str = start_date.strftime("%Y-%m-%d")
|
50 |
+
end_date_str = end_date.strftime("%Y-%m-%d")
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
# Join MeSH terms for query
|
53 |
query = " AND ".join([f'"{term}"[MeSH Terms]' for term in mesh_terms.split(",")])
|
|
|
107 |
lines=2
|
108 |
)
|
109 |
|
|
|
|
|
|
|
|
|
110 |
email_input = gr.Textbox(
|
111 |
label="Email",
|
112 |
placeholder="Your email (required by PubMed API)",
|
|
|
127 |
|
128 |
search_button.click(
|
129 |
fn=pubmed_search,
|
130 |
+
inputs=[mesh_terms_box, email_input],
|
131 |
outputs=[status_output, markdown_file, text_file]
|
132 |
)
|
133 |
|