-
Notifications
You must be signed in to change notification settings - Fork 0
/
qria.py
40 lines (29 loc) · 970 Bytes
/
qria.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
from flask import Flask, render_template, request, g
import json
from vocabulary import analyze_hard_vocabulary
app = Flask(__name__)
@app.route('/')
@app.route('/index')
def index():
return render_template('index.html')
@app.route('/api/message')
def send_message():
message = request.args.get('message', None)
if not message:
return 'message is required!'
return 'message sent! %s' % message
@app.route('/echo_webhook', methods=['POST'])
def echo_webhook():
"""Echo webhook data """
data = json.loads(request.data.decode())
print('Webhook received:', data)
return str(data)
@app.route('/text_analyzer', methods=['GET', 'POST'])
def text_analyzer():
# text = 'Hello horrifying world!'
text = request.form.get('text', None, type=str)
if text:
definitions = analyze_hard_vocabulary(text)
return render_template('text_analyzer.html', **locals())
if __name__ == '__main__':
app.run(debug=True)