datien228 commited on
Commit
0ce49a8
·
1 Parent(s): 734b8bf
Files changed (1) hide show
  1. app.py +14 -11
app.py CHANGED
@@ -5,7 +5,9 @@ from flask_cors import CORS, cross_origin
5
  import __main__
6
 
7
  app = Flask(__name__)
8
- cors = CORS(app, supports_credentials=True, resources={r"/summarize/*": {"origins": "http://0.0.0.0/summarize"}})
 
 
9
  # shortTokenizer = BartTokenizer.from_pretrained('sshleifer/distilbart-xsum-12-6')
10
  # shortModel = BartForConditionalGeneration.from_pretrained('sshleifer/distilbart-xsum-12-6')
11
 
@@ -30,24 +32,25 @@ def recommend():
30
  short_output_summary, long_output_summary = summarize(input_text)
31
  response = jsonify({'short': short_output_summary.strip(), 'long': long_output_summary.strip()})
32
  # Pass output summary to the output template
33
- response.headers['Access-Control-Allow-Methods'] = '*'
34
- response.headers['Access-Control-Allow-Domain'] = '*'
35
- response.headers['Access-Control-Allow-Credentials'] = True
 
36
  return response
37
 
38
  except Exception as e:
39
  return render_template('index.html', query=e)
40
 
41
  elif request.method == "OPTIONS":
42
- resp = make_response("OK")
43
- resp.status_code = 201
44
- # resp.headers['Access-Control-Allow-Origin'] = 'http://0.0.0.0'
45
- resp.headers['Access-Control-Allow-Methods'] = '*'
46
- resp.headers['Access-Control-Allow-Domain'] = '*'
47
- resp.headers['Access-Control-Allow-Credentials'] = True
48
  # Debug
49
  print("Right")
50
- return resp
51
 
52
  pass
53
 
 
5
  import __main__
6
 
7
  app = Flask(__name__)
8
+ CORS(app, resources={r"/*": {"origins": "http://0.0.0.0:7860"}}, supports_credentials=True)
9
+ app.config['CORS_ALLOW_HEADERS'] = 'Content-Type'
10
+ app.config['CORS_SUPPORTS_CREDENTIALS'] = 'True'
11
  # shortTokenizer = BartTokenizer.from_pretrained('sshleifer/distilbart-xsum-12-6')
12
  # shortModel = BartForConditionalGeneration.from_pretrained('sshleifer/distilbart-xsum-12-6')
13
 
 
32
  short_output_summary, long_output_summary = summarize(input_text)
33
  response = jsonify({'short': short_output_summary.strip(), 'long': long_output_summary.strip()})
34
  # Pass output summary to the output template
35
+ response.headers.add('Access-Control-Allow-Origin', 'http://0.0.0.0:7860')
36
+ response.headers.add('Access-Control-Allow-Headers', 'Content-Type, Authorization')
37
+ response.headers.add('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS')
38
+ response.headers.add('Access-Control-Allow-Credentials', 'true')
39
  return response
40
 
41
  except Exception as e:
42
  return render_template('index.html', query=e)
43
 
44
  elif request.method == "OPTIONS":
45
+ response = make_response("OK")
46
+ response.status_code = 201
47
+ response.headers.add('Access-Control-Allow-Origin', 'http://0.0.0.0:7860')
48
+ response.headers.add('Access-Control-Allow-Headers', 'Content-Type, Authorization')
49
+ response.headers.add('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS')
50
+ response.headers.add('Access-Control-Allow-Credentials', 'true')
51
  # Debug
52
  print("Right")
53
+ return response
54
 
55
  pass
56