File size: 592 Bytes
121a1b0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from flask import Flask, request, session
from flask import render_template, redirect, url_for
from twilio.twiml.messaging_response import MessagingResponse
from joy import ask

app = Flask(__name__)

#app.config[‘SECRET_KEY’] = ‘any-random-string’ what is this for?

@app.route('/joy', methods=['POST'])
def joy():
    incoming_msg = request.values['Body']
    chat_log = session.get('chat_log')
    answer, session['chat_log'] = ask(incoming_msg, chat_log)
    msg = MessagingResponse()
    msg.message(answer)
    return str(msg)

if __name__ == '__main__':
    app.run(debug=True)