The hompeage now shows a random quote instead of a news thing
This commit is contained in:
parent
601a45c8ae
commit
0211771bfd
1 changed files with 14 additions and 5 deletions
|
@ -1,4 +1,5 @@
|
|||
import datetime
|
||||
import random
|
||||
import logging
|
||||
import psycopg2
|
||||
from flask import render_template, Markup, request, abort, session, g
|
||||
|
@ -36,7 +37,15 @@ def index():
|
|||
datetime.datetime.now().strftime("%d/%m/%y"),
|
||||
conf.config['APPNAME']
|
||||
)
|
||||
|
||||
|
||||
#Show random quote on the homepage if any exist
|
||||
quotes = Quote.query.filter_by(approved=True).order_by(Quote.id.desc())all()
|
||||
numOfQuotes = len(quotes)
|
||||
if len(quotes)>0:
|
||||
quoteNum = random.choice(range(1,numOfQuotes+1))
|
||||
quote = quotes[quoteNum]
|
||||
news = str(Markup.escape(quote.content)).replace('\n', '<br />')
|
||||
|
||||
return render_template(
|
||||
"index.html",
|
||||
title="Quotes",
|
||||
|
@ -52,10 +61,10 @@ def login_page():
|
|||
session['authorized'] = True
|
||||
|
||||
return render_template(
|
||||
"login.html",
|
||||
)
|
||||
|
||||
|
||||
"login.html",
|
||||
)
|
||||
|
||||
|
||||
@app.route('/latest')
|
||||
def latest():
|
||||
quotes = Quote.query.filter_by(approved=True).order_by(Quote.id.desc()).all()
|
||||
|
|
Loading…
Add table
Reference in a new issue