Exemplo n.º 1
0
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)
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
def index():
    quote = Quote.get_random()
    tmpl = env.get_template('main.html')
    return tmpl.render(id=quote.id, body=quote.body)