-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
42 lines (38 loc) · 1.19 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
42
from flask import Flask ,request, jsonify, render_template
import pickle
import numpy as np
from cloud.word_cloud import wordtoplot
import pandas as pd
import pickle
import numpy as np
import matplotlib.pyplot as plt
from os import path
import time
# from common import TestView
app=Flask(__name__)
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
@app.after_request
def add_header(response):
# response.cache_control.no_store = True
response.headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0'
response.headers['Pragma'] = 'no-cache'
response.headers['Expires'] = '-1'
return response
@app.route('/')
def home():
return render_template('index.html')
@app.route('/predict', methods=['POST'])
def predict():
doc=str(request.form['txarea'])
# print(doc)
with app.test_request_context():
obj=wordtoplot(doc)
obj.clean_text()
obj.do_lemma()
obj.make_df()
obj.word_plot()
obj.common_plot()
topics=obj.get_topics()
return render_template('predict.html',topics=topics)
if __name__ == "__main__":
app.run(host='localhost', debug=True)