Lennox Kanyoe Kahati commited on
Commit
32a5df8
·
1 Parent(s): 7513a33

Fix CORS headers for mobile browser compatibility

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -38,7 +38,8 @@ load_dotenv()
38
 
39
  app = Flask(__name__)
40
  app.secret_key = 'adaptive_learning_secret_key_2024'
41
- CORS(app, supports_credentials=True)
 
42
 
43
  # Initialize components
44
  transcriber = pipeline("automatic-speech-recognition", model="openai/whisper-base.en")
@@ -1025,10 +1026,8 @@ def puzzles():
1025
  #return html file for games
1026
  return render_template('anatomy_puzzle.html')
1027
 
1028
- @app.route('/api/generate_trivia', methods=['POST', 'OPTIONS'])
1029
  def generate_trivia():
1030
- if request.method == 'OPTIONS':
1031
- return jsonify({'success': True})
1032
  try:
1033
  data = request.json
1034
  prompt = data.get('prompt')
 
38
 
39
  app = Flask(__name__)
40
  app.secret_key = 'adaptive_learning_secret_key_2024'
41
+ # Allow all origins and methods for the API to ensure mobile browsers work correctly
42
+ CORS(app, resources={r"/api/*": {"origins": "*"}}, supports_credentials=True)
43
 
44
  # Initialize components
45
  transcriber = pipeline("automatic-speech-recognition", model="openai/whisper-base.en")
 
1026
  #return html file for games
1027
  return render_template('anatomy_puzzle.html')
1028
 
1029
+ @app.route('/api/generate_trivia', methods=['POST'])
1030
  def generate_trivia():
 
 
1031
  try:
1032
  data = request.json
1033
  prompt = data.get('prompt')