Spaces:
Runtime error
Runtime error
add POST method
Browse files- app.py +19 -18
- 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 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
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"
|