def search(): if request.method == "GET": quotes = Quote.list(request.args.get('query')) tmpl = env.get_template('search.html') return tmpl.render(quotes=quotes) else: term = request.form['query'] results = Quote.search(term) to_return = [] for result in results: to_return.append({ "id":result.id, "body": result.body }) return json.dumps(to_return)
def home(): num = randint(1, 2706) color = choice(bgs) q = Quote(num) author = str(q['AUTHOR']) quote = q['QUOTE'] nan = "nan" return render_template("index.html", quote=quote, author=author, nan=nan, color=color)
def index(): quote = Quote.get_random() tmpl = env.get_template('main.html') return tmpl.render(id=quote.id, body=quote.body)