-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviews.py
More file actions
127 lines (103 loc) · 4.07 KB
/
views.py
File metadata and controls
127 lines (103 loc) · 4.07 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import pandas as pd
from IPython.core.display import HTML
from flask import Blueprint, render_template, request, Flask, jsonify, Response, render_template_string, url_for
from Classes.Model import Model
from Classes.ModelCall import ModelCall
from flask_cors import CORS
from Classes.RnnModel import RnnModel
views = Blueprint(__name__, "views")
CORS(views)
@views.route("/")
def home():
return render_template("index.html")
@views.route('/multiple_prediction', methods=['GET', "POST"])
def multiple_prediction():
if request.method == 'POST':
file = request.files['file']
df = pd.read_csv(file, usecols=['issuekey', "description"])
df['storypoint'] = ''
# csv_data = df.to_csv(index=False)
# return csv_data
data_str = df.to_html()
return data_str
else:
return render_template('multiple_prediction.html')
@views.route('/explain_prediction', methods=['GET', 'POST'])
def explain_prediction():
if request.method == 'POST':
user_story = request.form['userStory']
choice = request.form['choice']
final_sp = ModelCall.call_to_model(int(choice), str(user_story))
print(final_sp)
sp_value = final_sp[0]
return jsonify({'story_point': str(sp_value[0])})
else:
return render_template('explainPrediction.html')
@views.route("/from", methods=["POST"])
def form():
user_story = request.form.get("userstory")
print(user_story)
choice = 1
final_sp = ModelCall.call_to_model(1, user_story)
sp_value = Model.max_occurrence(final_sp)
return render_template("form.html", user_story=user_story, story_point=sp_value[0])
@views.route('/userStory', methods=['POST'])
def get_user_point():
user_story = request.get_json()
choice = request.args.get("choice")
print(user_story['user_story'])
final_sp = ModelCall.call_to_model(int(choice), str(user_story['user_story']))
print(final_sp)
if choice == '1':
sp_value = Model.max_occurrence(final_sp)
print(sp_value[0])
return jsonify({'story_point': str(sp_value[0])})
elif choice == '2':
sp_value = Model.max_occurrence(final_sp)
print(sp_value[0])
return jsonify({'story_point': str(sp_value[0])})
elif choice == '3':
sp_value = final_sp[0]
return jsonify({'story_point': str(sp_value[0])})
elif choice == '4':
sp_value = final_sp[0]
return jsonify({'story_point': str(sp_value[0])})
elif choice == '5':
sp_value = final_sp[0]
return jsonify({'story_point': str(sp_value[0])})
@views.route('/explain', methods=['POST'])
def get_explainer():
data = request.get_json()
user_story = data['userStory']
print(user_story)
# predicted_value = data['predictedValue']
response_data = ModelCall.call_to_explain(user_story)
# response = Response(response_data, mimetype='image/png')
return response_data
@views.route('/explainTest', methods=['POST'])
def get_explainer_test():
data = request.get_json()
user_story = data['userStory']
print(user_story)
# predicted_value = data['predictedValue']
response_data = ModelCall.call_to_explain_test(user_story)
# html_page = render_template('text.html', content=response_data)
# print(html_page)
# response = Response(response_data, mimetype='html')
return response_data
@views.route('/explainCustom', methods=['POST'])
def get_explainer_custom():
data = request.get_json()
user_story = data['userStory']
response_data = ModelCall.call_to_explain_custom(user_story)
html_string = response_data.data
return Response(html_string, content_type='text/html')
@views.route('/explainTestWeb', methods=['POST', 'GET'])
def get_explainer_test_web():
user_story = request.form.get("message")
# print(data)
# user_story = "I want to send a response as a html and show under the current page using flask"
# print(user_story)
response_data = ModelCall.call_to_explain_test(user_story)
# html = render_template(''response_data)
return render_template("text.html", content=response_data)