Skip to content
This repository was archived by the owner on Feb 3, 2024. It is now read-only.

Commit a4dc0f1

Browse files
committed
Add Route for Random Plaintext Quote
Added /random route which will provide a non-hidden quote selected at random from the database.
1 parent 2e8ccd6 commit a4dc0f1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

quotefault/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,15 @@ def hidden():
374374
metadata=metadata
375375
)
376376

377+
@app.route('/random', methods=['GET'])
378+
@auth.oidc_auth
379+
def random_quote():
380+
quote = db.session.execute("SELECT * FROM quotefault.quote WHERE hidden=0 ORDER BY RAND() LIMIT 1;").all()[0]
381+
#quote = get_quote_query(speaker = request.args.get('speaker'),
382+
# submitter = request.args.get('submitter')).order_by(func.rand()).limit(1).all()[0][0]
383+
out = f"{quote[2]} -{quote[3]} (Submitted by {quote[1]})"
384+
return out, 200
385+
377386
@app.errorhandler(403)
378387
def forbidden(e):
379388
return render_template('bootstrap/403.html', metadata=get_metadata()), 403

0 commit comments

Comments
 (0)