somoncef commited on
Commit
934cffc
·
1 Parent(s): 2230bf7

fea:Adding API key filtering on Predict endpoint

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -265,13 +265,13 @@ def warm_up_models():
265
  with app.app_context():
266
  warm_up_models()
267
 
268
- # @app.before_request
269
- # def check_rapidapi_key():
270
- # """Verify RapidAPI key for security"""
271
- # if request.path == '/predict':
272
- # rapidapi_key = request.headers.get('X-RapidAPI-Key')
273
- # if not rapidapi_key:
274
- # return jsonify({'error': 'Missing X-RapidAPI-Key header'}), 401
275
 
276
  @app.route('/predict', methods=['POST'])
277
  def predict():
 
265
  with app.app_context():
266
  warm_up_models()
267
 
268
+ @app.before_request
269
+ def check_rapidapi_key():
270
+ """Verify RapidAPI key for security"""
271
+ if request.path == '/predict':
272
+ rapidapi_key = request.headers.get('X-RapidAPI-Key')
273
+ if not rapidapi_key:
274
+ return jsonify({'error': 'Missing X-RapidAPI-Key header'}), 401
275
 
276
  @app.route('/predict', methods=['POST'])
277
  def predict():