from flask import Flask, render_template, render_template_string, request import requests import xmltodict import json 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"
" html+=f"
{c['title']}
" html+=f"
{c['summary']}
" html+=f"
{pdflink}
" html+="
" #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='7860')