-
Notifications
You must be signed in to change notification settings - Fork 34
/
expresso.py
42 lines (27 loc) · 878 Bytes
/
expresso.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
from flask import Flask, render_template, request, jsonify, g
import os
from text_analysis import analyze_text
app = Flask(__name__)
app.config.update(**os.environ)
@app.route('/')
def expresso_route():
return render_template('expresso.html')
@app.route('/how-to-use')
def how_to_use_route():
return render_template('how-to-use.html')
@app.route('/metrics')
def metrics_route():
return render_template('metrics.html')
@app.route('/tutorial')
def tutorial_route():
return render_template('tutorial.html')
@app.route('/about')
def about_route():
return render_template('about.html')
@app.route('/analyze-text', methods=['POST'])
def analyze():
html = request.form.get('html', '')
text, tokens, metrics = analyze_text(html)
return jsonify({'text': text, 'tokens': tokens, 'metrics': metrics})
if __name__ == '__main__':
app.run()