This repository has been archived by the owner on May 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalexa-app.py
59 lines (39 loc) · 1.66 KB
/
alexa-app.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from flask import Flask, render_template
from flask_ask import Ask, statement, question, session
from PEP_INDEX import PEP_INDEX
app = Flask(__name__)
ask = Ask(app, "/")
@app.route('/')
def index():
return "DFW Python Meetup"
@ask.launch
def launch():
return question(render_template('welcome')).reprompt(render_template('welcome_reprompt')).simple_card('Python Info - Launch', render_template('welcome'))
@ask.intent('GetPythonHistory')
def get_python_history():
return statement(render_template('history')).simple_card('Get Python History', render_template('history'))
@ask.intent('GetPythonReleaseInfo')
def get_python_release():
return statement(render_template('next_python_release')).simple_card('Get Python Release Info', render_template('history'))
@ask.intent('GetPEPInfo', mapping={'index': 'index'})
def get_pep_info(index):
if not index:
question_text = 'What is PEP index number ?'
return question(question_text).simple_card('Get PEP Info', question_text)
pep_text = PEP_INDEX.get(index, 'invalid')
pep_info = f'PEP {index} is {pep_text}'
return statement(pep_info).simple_card(f'Get PEP Info - PEP {index}', pep_info)
@ask.intent('AMAZON.HelpIntent')
def cancel():
print('AMAZON.HelpIntent')
return statement(render_template('welcome')).simple_card('Python Info - Launch', render_template('welcome'))
@ask.intent('AMAZON.StopIntent')
def stop():
print('AMAZON.StopIntent')
return statement('Okay, thank you for using Python Info Skill')
@ask.intent('AMAZON.CancelIntent')
def cancel():
print('AMAZON.CancelIntent')
return statement('Allright')
if __name__ == '__main__':
app.run(debug=True)