broadfield commited on
Commit
a235177
·
verified ·
1 Parent(s): 9cfd18b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -46
app.py CHANGED
@@ -1,47 +1,22 @@
1
- from flask import Flask, render_template, render_template_string, request
2
- import requests
3
  import xmltodict
4
- import json
5
- import random
6
-
7
- app = Flask(__name__)
8
- app.secret_key = "5rRRE6tk43D54e8e"
9
-
10
- api="http://export.arxiv.org/api/query?search_query=SQ&start=0&max_results=MR"
11
-
12
- style="""
13
- .title_div{
14
- font-size: x-large;
15
- font-weight: 700;
16
- margin-bottom: 10px;
17
- }
18
- .card_div{
19
- background: #050523;
20
- margin: 10px;
21
- padding: 15px;
22
- border-radius: 5px;
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()