karthikmohan409 commited on
Commit
e891a82
·
verified ·
1 Parent(s): 55bf594

Upload main.py

Browse files
Files changed (1) hide show
  1. main.py +10 -15
main.py CHANGED
@@ -7,7 +7,7 @@ import tempfile
7
 
8
  #app = Flask(__name__)
9
 
10
- app = Flask(__name__, static_folder='static')
11
 
12
  CORS(app, supports_credentials=True)
13
  #CORS(app, supports_credentials=True, resources={r"/*": {"origins": "*"}}) # Allow requests from any originorigins=["http://localhost:3000"])
@@ -43,8 +43,8 @@ def process_images():
43
  user_image = temp_path_1
44
 
45
  gen_vton(user_image, dress_image)
46
- processed_image_1_path = './processed-images/output_image.jpg'
47
- processed_image_2_path = './processed-images/output_image.jpg'
48
 
49
  # Save your images using the paths above...
50
 
@@ -58,19 +58,14 @@ def process_images():
58
  os.remove(temp_path_1)
59
  return jsonify({'processedImages': processed_image_urls})
60
 
61
- @app.route('/processed_images')
62
- def processed_images():
 
 
63
  # Example of generating a unique filename for the output
64
- import uuid
65
- output_filename = f"{uuid.uuid4()}.jpg"
66
- processed_image_path = os.path.join('processed-images', output_filename)
67
-
68
- # After processing and saving your image to processed_image_path
69
- url_to_processed_image = request.host_url + 'static/' + output_filename
70
-
71
- return jsonify({'processedImages': [url_to_processed_image]})
72
 
73
- # return send_from_directory(app.static_folder, filename)
74
 
75
  if __name__ == '__main__':
76
- app.run()
 
7
 
8
  #app = Flask(__name__)
9
 
10
+ app = Flask(__name__, static_folder='processed_images')
11
 
12
  CORS(app, supports_credentials=True)
13
  #CORS(app, supports_credentials=True, resources={r"/*": {"origins": "*"}}) # Allow requests from any originorigins=["http://localhost:3000"])
 
43
  user_image = temp_path_1
44
 
45
  gen_vton(user_image, dress_image)
46
+ processed_image_1_path = './processed_images/output_image.jpg'
47
+ processed_image_2_path = './processed_images/output_image_1.jpg'
48
 
49
  # Save your images using the paths above...
50
 
 
58
  os.remove(temp_path_1)
59
  return jsonify({'processedImages': processed_image_urls})
60
 
61
+ @app.route('/processed_images/<filename>')
62
+ def processed_images(filename):
63
+ print("request_came_here")
64
+ return send_from_directory(app.static_folder, filename)
65
  # Example of generating a unique filename for the output
66
+
 
 
 
 
 
 
 
67
 
68
+ #
69
 
70
  if __name__ == '__main__':
71
+ app.run(debug=True, host='0.0.0.0')