-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
39 lines (27 loc) · 771 Bytes
/
main.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
33
34
35
36
37
38
39
import logging
import json
from flask import Flask, render_template
from flask_ask import Ask, statement, question, session
app = Flask(__name__)
ask = Ask(app, "/")
logging.getLogger("flask_ask").setLevel(logging.DEBUG)
@ask.launch
def welcome():
"""
Message that runs on app launch
"""
return question(render_template('welcome'))
@ask.intent("ReadStoryIntent")
def read_story():
"""
Returns the day's story.
"""
story = None
with open("story.json", "r") as f:
story = json.loads(f.read())
if not story:
return statement('story_error')
story = render_template('story', title=story.get('title'), body=story.get('body'))
return statement(story)
if __name__ == '__main__':
app.run(debug=True)