Commit 450bcf20 authored by Rien's avatar Rien

Add /quote route

parent 7ab27fd9
......@@ -5,6 +5,7 @@ from flask_sqlalchemy import SQLAlchemy
from flask_migrate import Migrate
import requests
import config
import random
import re
import pdb
......@@ -148,6 +149,13 @@ def add_quote():
db.session.commit()
return mattermost_response("{} added the quote \"{}\"".format(user, quote_text))
@app.route('/quote', methods=['GET'])
def random_quote():
text_contains = request.values['text']
matches = models.Quote.query.filter(models.Quote.quote.contains(text_contains))
return mattermost_response(random.choice(matches))
@app.route('/', methods=['GET'])
def list_quotes():
return render_template('quotes.html', quotes = reversed(models.Quote.query.all()))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment