Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -49,26 +49,26 @@ print('Models Loaded Successfully')
|
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
|
| 73 |
@app.route('/', methods=['POST'])
|
| 74 |
def post_data():
|
|
|
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
+
@app.route('/', methods=['GET'])
|
| 53 |
+
def get_data():
|
| 54 |
+
img = plt.imread('test1.jpeg')
|
| 55 |
+
img_arr = np.array(img)
|
| 56 |
+
pil_img = Image.fromarray(img_arr.astype(np.uint8))
|
| 57 |
+
buffered = io.BytesIO()
|
| 58 |
+
pil_img.save(buffered, format="JPEG")
|
| 59 |
+
img_str = base64.b64encode(buffered.getvalue()).decode()
|
| 60 |
+
|
| 61 |
+
data = {
|
| 62 |
+
'message': 'Hello, World!',
|
| 63 |
+
'items': [1, 2, 3, 4, 5],
|
| 64 |
+
'image': img_str
|
| 65 |
+
}
|
| 66 |
+
return jsonify(data)
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
@app.route('/test')
|
| 70 |
+
def home():
|
| 71 |
+
return "Welcome to the Flask API!"
|
| 72 |
|
| 73 |
@app.route('/', methods=['POST'])
|
| 74 |
def post_data():
|