nagasurendra commited on
Commit
9a9d5c5
·
verified ·
1 Parent(s): 17d84f4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -4,6 +4,11 @@ import os
4
 
5
  app = Flask(__name__)
6
 
 
 
 
 
 
7
  # Endpoint to handle the image
8
  @app.route('/upload', methods=['POST'])
9
  def upload_image():
@@ -15,10 +20,12 @@ def upload_image():
15
 
16
  # Decode the base64 string and save the image
17
  img_data = base64.b64decode(data)
18
- with open('captured_image.png', 'wb') as f:
 
 
19
  f.write(img_data)
20
 
21
- return jsonify({"message": "Image saved successfully!"})
22
 
23
  # Homepage
24
  @app.route('/')
 
4
 
5
  app = Flask(__name__)
6
 
7
+ # Folder where images will be saved
8
+ UPLOAD_FOLDER = 'uploads'
9
+ if not os.path.exists(UPLOAD_FOLDER):
10
+ os.makedirs(UPLOAD_FOLDER)
11
+
12
  # Endpoint to handle the image
13
  @app.route('/upload', methods=['POST'])
14
  def upload_image():
 
20
 
21
  # Decode the base64 string and save the image
22
  img_data = base64.b64decode(data)
23
+ file_path = os.path.join(UPLOAD_FOLDER, 'captured_image.png')
24
+
25
+ with open(file_path, 'wb') as f:
26
  f.write(img_data)
27
 
28
+ return jsonify({"message": "Image saved successfully!", "path": file_path})
29
 
30
  # Homepage
31
  @app.route('/')