kumar9 commited on
Commit
bf01bb4
1 Parent(s): 09b9b64

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +12 -20
main.py CHANGED
@@ -25,23 +25,15 @@ def get():
25
  data = query({"inputs": "The movie is good"})
26
  return data
27
 
28
- @app.route('/', methods=['POST'])
29
- def predict():
30
- message = "This is good movies" #request.form['message']
31
- # choice of the model
32
- results = get_prediction(message, dictOfModels['BERT']) # get_prediction(message, dictOfModels['request.form.get("model_choice")'])
33
- print(f'User selected model : {request.form.get("model_choice")}')
34
- my_prediction = f'The feeling of this text is {results[0]["label"]} with probability of {results[0]["score"]*100}%.'
35
- return render_template('result.html', text = f'{message}', prediction = my_prediction)
36
-
37
-
38
-
39
- # @app.route('/')
40
- # def home():
41
- # print(1)
42
- # return {'key':"Hello HuggingFace! Successfully deployed. "}
43
- # # model = load_checkpoint('checkpoint.pth')
44
- # # print(2)
45
- # # res = sample(model, obj.maxlen, 'ap')
46
- # # print(3)
47
- # # return {'key':res}
 
25
  data = query({"inputs": "The movie is good"})
26
  return data
27
 
28
+ @app.route("/", methods=["GET", "POST"])
29
+ def index():
30
+ user_input = None
31
+ response = None
32
+
33
+ if request.method == "POST":
34
+ user_input = request.form.get("user_input")
35
+ response = query({"inputs": user_input})
36
+
37
+
38
+ return render_template("index.html", user_input=user_input, response=response)
39
+