-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
executable file
·41 lines (33 loc) · 1.06 KB
/
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
from flask import Flask, render_template, request
import json
from src import controller
# flask read views in "templates" folder
# flask read asset in "static" folder
app = Flask(__name__)
# code started here
@app.route('/eval_training')
def to_form():
return render_template('/views/eval_training.html')
@app.route('/eval')
def eval_page():
return render_template('/views/eval.html')
@app.route('/')
def demo_page():
return render_template('/views/demo.html')
@app.route('/identify', methods=['GET'])
def san_headline_identification():
judul = request.args.get('title').strip()
word_judul, len_judul = controller.text_length(judul)
if word_judul > 3 and len_judul < 250 :
clean_txt = controller.clean(judul)
is_cb, acc = controller.identify_text(judul)
return json.dumps(
{
'judul': clean_txt,
'is_clickbait': is_cb,
'accuracy' : acc
}
), 200, {'ContentType': 'application/json'}
else :
return 500
app.run(debug=True,host="0.0.0.0")