yangyang158 commited on
Commit
1dd235a
·
1 Parent(s): 3b587d3

Feat: Set workers to 1, fix JSON parsing, and rename predict endpoint

Browse files
Files changed (2) hide show
  1. Dockerfile +1 -1
  2. app.py +3 -3
Dockerfile CHANGED
@@ -35,4 +35,4 @@ COPY --chown=appuser:appuser ./ .
35
  EXPOSE 7860
36
 
37
  # Set the default command to run the app with Gunicorn
38
- CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "2", "app:app"]
 
35
  EXPOSE 7860
36
 
37
  # Set the default command to run the app with Gunicorn
38
+ CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "app:app"]
app.py CHANGED
@@ -164,9 +164,9 @@ def get_available_models():
164
  """Returns the list of available models and their details."""
165
  return jsonify(AVAILABLE_MODELS)
166
 
167
- @app.route('/api/predict_from_data', methods=['POST'])
168
  @require_api_key
169
- def predict_from_data():
170
  """
171
  Receives raw K-line data in the request body, makes a prediction,
172
  and returns the results.
@@ -174,7 +174,7 @@ def predict_from_data():
174
  if not predictor:
175
  return jsonify({'error': 'Model not loaded. Please call /api/load-model first.'}), 400
176
 
177
- data = request.get_json()
178
  if not data or 'k_lines' not in data:
179
  return jsonify({'error': 'Missing "k_lines" in request body.'}), 400
180
 
 
164
  """Returns the list of available models and their details."""
165
  return jsonify(AVAILABLE_MODELS)
166
 
167
+ @app.route('/api/predict', methods=['POST'])
168
  @require_api_key
169
+ def predict():
170
  """
171
  Receives raw K-line data in the request body, makes a prediction,
172
  and returns the results.
 
174
  if not predictor:
175
  return jsonify({'error': 'Model not loaded. Please call /api/load-model first.'}), 400
176
 
177
+ data = request.get_json(force=True)
178
  if not data or 'k_lines' not in data:
179
  return jsonify({'error': 'Missing "k_lines" in request body.'}), 400
180