Spaces:
Sleeping
Sleeping
Commit
·
f5aa8bc
1
Parent(s):
9741e3f
again
Browse files
app.py
CHANGED
|
@@ -6,7 +6,7 @@ import base64
|
|
| 6 |
from scipy.linalg import svd
|
| 7 |
import os
|
| 8 |
|
| 9 |
-
app = Flask(__name__, static_url_path='/static')
|
| 10 |
|
| 11 |
def calculate_storage(shape, r_value):
|
| 12 |
if len(shape) == 3: # RGB image
|
|
@@ -101,12 +101,12 @@ 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(app.static_folder, image_url
|
| 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
|
|
@@ -118,6 +118,6 @@ def process():
|
|
| 118 |
return jsonify(result)
|
| 119 |
except Exception as e:
|
| 120 |
return jsonify({'error': str(e)}), 400
|
| 121 |
-
|
| 122 |
if __name__ == '__main__':
|
| 123 |
app.run(debug=True)
|
|
|
|
| 6 |
from scipy.linalg import svd
|
| 7 |
import os
|
| 8 |
|
| 9 |
+
app = Flask(__name__, static_folder='static', static_url_path='/static')
|
| 10 |
|
| 11 |
def calculate_storage(shape, r_value):
|
| 12 |
if len(shape) == 3: # RGB image
|
|
|
|
| 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[len('/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': f'Image file not found at {image_path}'}), 404
|
| 110 |
|
| 111 |
if not image_data:
|
| 112 |
return jsonify({'error': 'No image provided'}), 400
|
|
|
|
| 118 |
return jsonify(result)
|
| 119 |
except Exception as e:
|
| 120 |
return jsonify({'error': str(e)}), 400
|
| 121 |
+
|
| 122 |
if __name__ == '__main__':
|
| 123 |
app.run(debug=True)
|