Spaces:
Running
Running
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import Flask, render_template, render_template_string, request
|
| 2 |
+
import requests
|
| 3 |
+
import xmltodict
|
| 4 |
+
import json
|
| 5 |
+
app = Flask(__name__)
|
| 6 |
+
app.secret_key = "5rRRE6tk43D54e8e"
|
| 7 |
+
|
| 8 |
+
api="http://export.arxiv.org/api/query?search_query=SQ&start=0&max_results=MR"
|
| 9 |
+
|
| 10 |
+
style="""
|
| 11 |
+
.title_div{
|
| 12 |
+
font-size: x-large;
|
| 13 |
+
font-weight: 700;
|
| 14 |
+
margin-bottom: 10px;
|
| 15 |
+
}
|
| 16 |
+
.card_div{
|
| 17 |
+
background: #050523;
|
| 18 |
+
margin: 10px;
|
| 19 |
+
padding: 15px;
|
| 20 |
+
border-radius: 5px;
|
| 21 |
+
}
|
| 22 |
+
"""
|
| 23 |
+
@app.route("/", methods=['GET', 'POST'])
|
| 24 |
+
def home():
|
| 25 |
+
version = random.randint(1,11111111111111111111)
|
| 26 |
+
#def search(q,rn):
|
| 27 |
+
if request.method == 'POST':
|
| 28 |
+
# Create variables for easy access
|
| 29 |
+
q = request.form['query']
|
| 30 |
+
rn = request.form['count']
|
| 31 |
+
r=requests.get(s_url.replace("SQ",q).replace("MR",str(rn)))
|
| 32 |
+
cont=xmltodict.parse(r.content)['feed']['entry']
|
| 33 |
+
html=""
|
| 34 |
+
for i,c in enumerate(cont):
|
| 35 |
+
pdflink=c['id'].replace('/abs/','/pdf/')
|
| 36 |
+
html+=f"<div class='card_div' id='id{i}' onclick='fun_run()'>"
|
| 37 |
+
html+=f"<div class='titlebase'>{c['title']}</div>"
|
| 38 |
+
html+=f"<div>{c['summary']}</div>"
|
| 39 |
+
html+=f"<div><a href='{pdflink}' target='_blank'>{pdflink}</a></div>"
|
| 40 |
+
html+="</div>"
|
| 41 |
+
#return(json.dumps(cont,indent=4)),html
|
| 42 |
+
return render_template('index.html')
|
| 43 |
+
return render_template('index.html')
|
| 44 |
+
if __name__=="__main__":
|
| 45 |
+
app.run(host='0.0.0.0', port='7860')
|