Spaces:
Runtime error
Runtime error
add samesite attr to response header
Browse files- app.py +4 -3
- requirements.txt +0 -1
- templates/index.html +2 -2
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from flask import Flask, render_template, request, jsonify
|
2 |
from modules.model import summarize
|
3 |
import __main__
|
4 |
|
@@ -25,8 +25,9 @@ def recommend():
|
|
25 |
# Call the function summarize to run the text summarization
|
26 |
try:
|
27 |
short_output_summary, long_output_summary = summarize(input_text)
|
28 |
-
response = jsonify({'short': short_output_summary.strip(), 'long': long_output_summary.strip()})
|
29 |
-
response.
|
|
|
30 |
# Pass output summary to the output template
|
31 |
return response
|
32 |
|
|
|
1 |
+
from flask import Flask, render_template, request, jsonify, make_response
|
2 |
from modules.model import summarize
|
3 |
import __main__
|
4 |
|
|
|
25 |
# Call the function summarize to run the text summarization
|
26 |
try:
|
27 |
short_output_summary, long_output_summary = summarize(input_text)
|
28 |
+
response = make_response(jsonify({'short': short_output_summary.strip(), 'long': long_output_summary.strip()}))
|
29 |
+
response.set_cookie('cookie1', 'value1', samesite='Lax')
|
30 |
+
response.set_cookie('cookie2', 'value2', samesite='None', secure=True)
|
31 |
# Pass output summary to the output template
|
32 |
return response
|
33 |
|
requirements.txt
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
torch==1.11.0
|
2 |
Flask==2.1.0
|
3 |
transformers==4.20.0
|
4 |
-
# flask_cors==3.0.10
|
|
|
1 |
torch==1.11.0
|
2 |
Flask==2.1.0
|
3 |
transformers==4.20.0
|
|
templates/index.html
CHANGED
@@ -190,7 +190,7 @@
|
|
190 |
const translateText = async (jsonfile) => {
|
191 |
const fetchSettings = {
|
192 |
method: 'POST',
|
193 |
-
mode: 'no-cors',
|
194 |
};
|
195 |
const inferResponse = await fetch(`/summarize?input=${jsonfile}`, fetchSettings);
|
196 |
const inferJson = await inferResponse.json();
|
@@ -214,7 +214,7 @@
|
|
214 |
// var data = {"input_text": textGenInput.value};
|
215 |
|
216 |
try {
|
217 |
-
data_out = await translateText(textGenInput.value);
|
218 |
$("#check").attr('checked', true);
|
219 |
$("#input_text").attr("readonly", false);
|
220 |
$("#load-noti").text("Completed")
|
|
|
190 |
const translateText = async (jsonfile) => {
|
191 |
const fetchSettings = {
|
192 |
method: 'POST',
|
193 |
+
mode: 'no-cors',
|
194 |
};
|
195 |
const inferResponse = await fetch(`/summarize?input=${jsonfile}`, fetchSettings);
|
196 |
const inferJson = await inferResponse.json();
|
|
|
214 |
// var data = {"input_text": textGenInput.value};
|
215 |
|
216 |
try {
|
217 |
+
data_out = await translateText(JSON.stringify({"input_text": textGenInput.value}));
|
218 |
$("#check").attr('checked', true);
|
219 |
$("#input_text").attr("readonly", false);
|
220 |
$("#load-noti").text("Completed")
|