-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchores.py
32 lines (27 loc) · 966 Bytes
/
chores.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import logging
from flask import Flask, render_template
from flask_ask import Ask, statement, question, session
from config import CHORES
import datetime
app = Flask(__name__)
ask = Ask(app, "/")
logging.getLogger("flask_ask").setLevel(logging.DEBUG)
#@ask.launch
#def new_lookup():
# welcome_msg = render_template('welcome', day=weekday)
# return question(welcome_msg)
@ask.intent("TurnIntent", convert={'chore': str})
def whose_turn(chore):
weekday = datetime.datetime.today().strftime("%A")
msg = render_template('turn', name=CHORES[chore][weekday], chore=chore)
return statement(msg)
@ask.intent("ListIntent")
def list_chores():
weekday = datetime.datetime.today().strftime("%A")
chore_list = []
for chore in CHORES.keys():
chore_list.append((chore, CHORES[chore][weekday]))
msg = render_template('list', day=weekday, chores=chore_list)
return statement(msg)
if __name__ == '__main__':
app.run(debug=True)