NarutoKeeper
@app.route('/search')
def search():
if 'username' not in session:
return redirect('/login')
if 'query' not in request.args:
return redirect('/home')
query = str(request.args.get('query'))
results = get_pastes(session['username'])
res_content=[{"id":id,"val":get_paste(id)} for id in results]
if ":" in query:
toGo=get_paste(query.split(":")[1])
sear=query.split(":")[0]
else:
toGo=res_content[0]["val"]
sear=query
i=0
for paste in res_content:
i=i+1
if i>5:
return redirect("/view?id=MaximumReached&paste="+toGo.strip())
if sear in paste["val"]:
return redirect("/view?id=Found&paste="+toGo.strip())
return render_template("search.html",error='No results found.',result="")
Last updated