rohan13 commited on
Commit
f4af02c
1 Parent(s): 2376116

added cors

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -1,11 +1,12 @@
1
  from flask import Flask, render_template
2
  from flask_socketio import SocketIO, emit
 
3
  from main import run
4
 
5
  app = Flask(__name__)
6
  app.config['SECRET_KEY'] = 'secret!'
7
- socketio = SocketIO(app)
8
-
9
 
10
  @app.route('/')
11
  def index():
@@ -13,6 +14,7 @@ def index():
13
 
14
 
15
  @socketio.on('message')
 
16
  def handle_message(data):
17
  question = data['question']
18
  print("question: " + question)
@@ -21,4 +23,4 @@ def handle_message(data):
21
 
22
 
23
  if __name__ == '__main__':
24
- socketio.run(app)
 
1
  from flask import Flask, render_template
2
  from flask_socketio import SocketIO, emit
3
+ from flask.ext.cors import cross_origin, CORS
4
  from main import run
5
 
6
  app = Flask(__name__)
7
  app.config['SECRET_KEY'] = 'secret!'
8
+ socketio = SocketIO(app, cors_allowed_origins="*")
9
+ cors = CORS(app)
10
 
11
  @app.route('/')
12
  def index():
 
14
 
15
 
16
  @socketio.on('message')
17
+ @cross_origin
18
  def handle_message(data):
19
  question = data['question']
20
  print("question: " + question)
 
23
 
24
 
25
  if __name__ == '__main__':
26
+ socketio.run(app, allow_unsafe_werkzeug=True)