from flask import Flask, request, jsonify from flask_cors import CORS from PIL import Image # Initialize the Flask app myapp = Flask(__name__) # Enable CORS for the app CORS(myapp) @myapp.route('/') def index(): return "Welcome to the AI Model Upscale!" @myapp.route('/resize', methods=['POST']) def resize_image(): data = request.json input_path = data.get('input_path') output_path = data.get('output_path') width = data.get('width') height = data.get('height') # Open an image file and resize it with Image.open(input_path) as img: resized_img = img.resize((width, height), Image.LANCZOS) resized_img.save(output_path) return jsonify({'message': 'Image resized successfully', 'output_path': output_path}) if __name__ == "__main__": myapp.run(host='0.0.0.0', port=5000)