Spaces:
Runtime error
Runtime error
no fetch setting
Browse files- app.py +18 -20
- templates/index.html +11 -11
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
from flask import Flask, render_template, request, jsonify, make_response
|
2 |
-
from flask_cors import CORS, cross_origin
|
3 |
from modules.model import summarize
|
4 |
import __main__
|
5 |
|
@@ -15,26 +15,24 @@ def home():
|
|
15 |
return render_template('index.html')
|
16 |
|
17 |
|
18 |
-
@app.route('/summarize'
|
19 |
-
@cross_origin()
|
20 |
def recommend():
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
return render_template('index.html', query=e)
|
38 |
|
39 |
pass
|
40 |
|
|
|
1 |
from flask import Flask, render_template, request, jsonify, make_response
|
2 |
+
# from flask_cors import CORS, cross_origin
|
3 |
from modules.model import summarize
|
4 |
import __main__
|
5 |
|
|
|
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.args.get("input")
|
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(message={'short': short_output_summary.strip(), 'long': long_output_summary.strip()})
|
30 |
+
response.headers.add("Access-Control-Allow-Origin", "*")
|
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 |
|
templates/index.html
CHANGED
@@ -188,17 +188,17 @@
|
|
188 |
// ======= COMMUNICATE WITH FLSAK BACK END TO RUN ML TASK =======
|
189 |
|
190 |
const translateText = async (jsonfile) => {
|
191 |
-
const fetchSettings = {
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
};
|
201 |
-
const inferResponse = await fetch(`/summarize
|
202 |
|
203 |
return inferResponse.json();
|
204 |
};
|
|
|
188 |
// ======= COMMUNICATE WITH FLSAK BACK END TO RUN ML TASK =======
|
189 |
|
190 |
const translateText = async (jsonfile) => {
|
191 |
+
// const fetchSettings = {
|
192 |
+
// method: 'POST',
|
193 |
+
// mode: 'cors',
|
194 |
+
// credentials: 'same-origin',
|
195 |
+
// body: JSON.stringify({"input_text": jsonfile}),
|
196 |
+
// headers: {
|
197 |
+
// "Content-Type": "application/json"
|
198 |
+
// },
|
199 |
+
// referrerPolicy: 'no-referrer'
|
200 |
+
// };
|
201 |
+
const inferResponse = await fetch(`/summarize?input=${jsonfile}`);
|
202 |
|
203 |
return inferResponse.json();
|
204 |
};
|