Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,47 +1,22 @@
|
|
1 |
-
|
2 |
-
import requests
|
3 |
import xmltodict
|
4 |
-
import
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
.
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
"""
|
25 |
-
@app.route("/", methods=['GET', 'POST'])
|
26 |
-
def home():
|
27 |
-
version = random.randint(1,11111111111111111111)
|
28 |
-
#def search(q,rn):
|
29 |
-
if request.method == 'POST':
|
30 |
-
# Create variables for easy access
|
31 |
-
q = request.form['query']
|
32 |
-
rn = request.form['count']
|
33 |
-
r=requests.get(s_url.replace("SQ",q).replace("MR",str(rn)))
|
34 |
-
cont=xmltodict.parse(r.content)['feed']['entry']
|
35 |
-
html=""
|
36 |
-
for i,c in enumerate(cont):
|
37 |
-
pdflink=c['id'].replace('/abs/','/pdf/')
|
38 |
-
html+=f"<div class='card_div' id='id{i}' onclick='fun_run()'>"
|
39 |
-
html+=f"<div class='titlebase'>{c['title']}</div>"
|
40 |
-
html+=f"<div>{c['summary']}</div>"
|
41 |
-
html+=f"<div><a href='{pdflink}' target='_blank'>{pdflink}</a></div>"
|
42 |
-
html+="</div>"
|
43 |
-
#return(json.dumps(cont,indent=4)),html
|
44 |
-
return render_template('index.html',version=version,html_out=html)
|
45 |
-
return render_template('index.html',version=version)
|
46 |
-
if __name__=="__main__":
|
47 |
-
app.run(host='0.0.0.0', port='8080')
|
|
|
1 |
+
import gradio as gr
|
|
|
2 |
import xmltodict
|
3 |
+
import requests
|
4 |
+
def search(q,rn)
|
5 |
+
r=requests.get(s_url.replace("SQ",q).replace("MR",str(rn)))
|
6 |
+
cont=xmltodict.parse(r.content)['feed']['entry']
|
7 |
+
html=""
|
8 |
+
for i,c in enumerate(cont):
|
9 |
+
pdflink=c['id'].replace('/abs/','/pdf/')
|
10 |
+
html+=f"<div class='card_div' id='id{i}' onclick='fun_run()'>"
|
11 |
+
html+=f"<div class='titlebase'>{c['title']}</div>"
|
12 |
+
html+=f"<div>{c['summary']}</div>"
|
13 |
+
html+=f"<div><a href='{pdflink}' target='_blank'>{pdflink}</a></div>"
|
14 |
+
html+="</div>"
|
15 |
+
return(json.dumps(cont,indent=4)),html
|
16 |
+
with gr.Blocks() as b:
|
17 |
+
with gr.Query():
|
18 |
+
with gr.Row():
|
19 |
+
query=gr.Textbox(label="Query")
|
20 |
+
num=gr.Number(label="Count",step=1,value=10)
|
21 |
+
sub=gr.Button()
|
22 |
+
b.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|