import requests from flask import Flask, jsonify app = Flask(__name__) @app.route('/get_waifu_image', methods=['GET']) def get_waifu_image(): try: response = requests.get('https://api.waifu.pics/sfw/waifu') response.raise_for_status() # Memastikan permintaan berhasil image_url = response.json().get('url') # Mengambil URL gambar return jsonify({"url": image_url}) # Mengembalikan hasil dalam format JSON except Exception as e: return jsonify({"error": str(e)}) if __name__ == "__main__": app.run(host='0.0.0.0', port=7860)