binaychandra commited on
Commit
9741e3f
·
1 Parent(s): a5c0e19

modification wrt image path

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -101,15 +101,18 @@ def process():
101
  elif 'image_url' in request.form:
102
  image_url = request.form['image_url']
103
  if image_url.startswith('/static/'):
104
- image_path = os.path.join(os.path.dirname(__file__), image_url[1:])
105
- with open(image_path, 'rb') as f:
106
- image_data = f.read()
107
-
 
 
 
108
  if not image_data:
109
  return jsonify({'error': 'No image provided'}), 400
110
 
111
  r_value = int(request.form.get('r_value', 1))
112
-
113
  try:
114
  result = process_image(image_data, r_value)
115
  return jsonify(result)
 
101
  elif 'image_url' in request.form:
102
  image_url = request.form['image_url']
103
  if image_url.startswith('/static/'):
104
+ image_path = os.path.join(app.static_folder, image_url.replace('/static/', ''))
105
+ if os.path.exists(image_path):
106
+ with open(image_path, 'rb') as f:
107
+ image_data = f.read()
108
+ else:
109
+ return jsonify({'error': 'Image file not found'}), 404
110
+
111
  if not image_data:
112
  return jsonify({'error': 'No image provided'}), 400
113
 
114
  r_value = int(request.form.get('r_value', 1))
115
+
116
  try:
117
  result = process_image(image_data, r_value)
118
  return jsonify(result)