File size: 1,514 Bytes
1748047
 
 
 
6c56be5
 
1748047
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6f539e1
f80b3ac
1748047
76903ee
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
from flask import Flask, render_template, render_template_string, request
import requests
import xmltodict
import json
import random

app = Flask(__name__)
app.secret_key = "5rRRE6tk43D54e8e"

api="http://export.arxiv.org/api/query?search_query=SQ&start=0&max_results=MR"

style="""
.title_div{
    font-size: x-large;
    font-weight: 700;
    margin-bottom: 10px;
}
.card_div{
    background: #050523;
    margin: 10px;
    padding: 15px;
    border-radius: 5px;
}
"""
@app.route("/", methods=['GET', 'POST'])
def home():
    version = random.randint(1,11111111111111111111)
    #def search(q,rn):
    if request.method == 'POST':
        # Create variables for easy access
        q = request.form['query']
        rn = request.form['count']
        r=requests.get(s_url.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='fun_run()'>"
            html+=f"<div class='titlebase'>{c['title']}</div>"
            html+=f"<div>{c['summary']}</div>"
            html+=f"<div><a href='{pdflink}' target='_blank'>{pdflink}</a></div>"
            html+="</div>"
        #return(json.dumps(cont,indent=4)),html
        return render_template('index.html',version=version,html_out=html)
    return render_template('index.html',version=version)
if __name__=="__main__":
    app.run(host='0.0.0.0', port='8080')