Spaces:
Running
Running
File size: 1,770 Bytes
a235177 1748047 a235177 75642d2 10ac278 341551d 10ac278 341551d 10ac278 310b87d 10ac278 b089d6a 6bf8b90 b089d6a c786d64 310b87d 943e97c 310b87d 4da7dd9 b089d6a 1a1ccf3 49cee1b 035484e 3d2bc32 a235177 310b87d 341551d 3bda8ad a235177 310b87d a235177 b089d6a 98aa43b a235177 7c2f2b2 49cee1b a235177 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
import gradio as gr
import xmltodict
import requests
import json
style="""
.title_div{
font-size: x-large;
font-weight: 700;
margin-bottom: 10px;
color: white;
}
.card_div{
background: #050523;
color: white;
margin: 10px;
padding: 15px;
border-radius: 5px;
}
.frame_class{
display:None;
}
"""
head = """
<script>
function run(inn) {
console.log(inn);
var frame_on = document.getElementById("frame" + String(inn));
/*frame_on.style.visbility = false;*/
frame_on.style.visbility = true;
}
</script>
""".replace("/abs/","/pdf/")
def search(q,rn):
api="http://export.arxiv.org/api/query?search_query=SQ&start=0&max_results=MR"
r=requests.get(api.replace("SQ",q).replace("MR",str(rn)))
cont=xmltodict.parse(r.content)['feed']['entry']
html=""
for i,c in enumerate(cont):
pdflink=c['id'].replace('/abs/','/pdf/')
html+=f"""<div class='card_div' id='id{i}' onclick="run({i})">"""
html+=f"<div class='title_div'>{c['title']}</div>"
html+=f"<div style='color:white;'>{c['summary']}</div>"
html+=f"<div><a href='{pdflink}' target='_blank'>{pdflink}</a></div>"
html+="</div>"
html+=f"""<div id=frame{i} class='frame_class'><iframe src="https://docs.google.com/viewer?url={c['id'].replace('/abs/','/pdf/')}&embedded=true" frameborder="0" height="1200px" width="100%"></iframe>"""
return(json.dumps(cont,indent=4)),html
with gr.Blocks(css=style,head=head) as b:
with gr.Group():
with gr.Row():
query=gr.Textbox(label="Query")
num=gr.Number(label="Count",step=1,value=10)
sub=gr.Button()
html_out=gr.HTML()
json_out=gr.JSON()
sub.click(search,[query,num],[json_out,html_out])
b.launch() |