35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
from os import getcwd, sep
|
|
from datetime import date
|
|
from flask import render_template
|
|
from app import app
|
|
|
|
def get_next_ride_date( rides_list ):
|
|
rides_list.sort()
|
|
active_rides = []
|
|
for ride_date in rides_list:
|
|
if ride_date > date.today():
|
|
active_rides.append( ride_date )
|
|
return active_rides[0]
|
|
|
|
|
|
@app.route('/')
|
|
@app.route('/index')
|
|
def index():
|
|
rides_file = open( getcwd() + sep + "data/rides.txt")
|
|
rides = [ date.strptime( ride_date_str ,"%Y/%m/%d") for ride_date_str in rides_file.read().split("\n") ]
|
|
next_ride = get_next_ride_date(rides)
|
|
user = {'username': 'Jorge'}
|
|
|
|
posts = [
|
|
{
|
|
'author': {'username':'Guybrush'},
|
|
'body': "How appropriate, you fight like a cow!"
|
|
},
|
|
{
|
|
'author': {'username':'LeChuck'},
|
|
'body': "I distinctly remember ordering a mystical voodo potion."
|
|
}
|
|
]
|
|
|
|
return render_template( 'index.html', title='Home', user=user, posts=posts, rides=rides, next_ride=next_ride) ## objects/variables to send over to templates.
|