datien228 commited on
Commit
27819ff
1 Parent(s): 7f67da7

add POST method

Browse files
Files changed (2) hide show
  1. app.py +19 -18
  2. templates/index.html +1 -0
app.py CHANGED
@@ -15,25 +15,26 @@ def home():
15
  return render_template('index.html')
16
 
17
 
18
- @app.route("/summarize")
19
  def recommend():
20
- # Get form data
21
- # request_data = request.args.get("input").get_json()
22
- # input_text = request_data['input_text']
23
- input_text = request.get_json()['input_text']
24
- print(input_text)
25
-
26
- # Call the function summarize to run the text summarization
27
- try:
28
- short_output_summary, long_output_summary = summarize(input_text)
29
- response = jsonify({'short': short_output_summary.strip(), 'long': long_output_summary.strip()})
30
- # Pass output summary to the output template
31
- return response
32
-
33
- except Exception as e:
34
- return render_template('index.html', query=e)
35
-
36
- pass
 
37
 
38
  if __name__ == '__main__':
39
  print("Loading BART model and tokenzier . . .")
 
15
  return render_template('index.html')
16
 
17
 
18
+ @app.route("/summarize", methods=["POST"])
19
  def recommend():
20
+ if request.method == "POST":
21
+ # Get form data
22
+ # request_data = request.args.get("input").get_json()
23
+ # input_text = request_data['input_text']
24
+ input_text = request.get_json()['input_text']
25
+ print(input_text)
26
+
27
+ # Call the function summarize to run the text summarization
28
+ try:
29
+ short_output_summary, long_output_summary = summarize(input_text)
30
+ response = jsonify({'short': short_output_summary.strip(), 'long': long_output_summary.strip()})
31
+ # Pass output summary to the output template
32
+ return response
33
+
34
+ except Exception as e:
35
+ return render_template('index.html', query=e)
36
+
37
+ pass
38
 
39
  if __name__ == '__main__':
40
  print("Loading BART model and tokenzier . . .")
templates/index.html CHANGED
@@ -189,6 +189,7 @@
189
 
190
  const translateText = async (jsonfile) => {
191
  const fetchSettings = {
 
192
  body: JSON.stringify({"input_text": jsonfile}),
193
  headers: {
194
  "Content-Type": "application/json"
 
189
 
190
  const translateText = async (jsonfile) => {
191
  const fetchSettings = {
192
+ method: 'POST',
193
  body: JSON.stringify({"input_text": jsonfile}),
194
  headers: {
195
  "Content-Type": "application/json"