File size: 581 Bytes
fe25e4b
32e2299
fe25e4b
32e2299
 
 
fe25e4b
 
 
fbfac61
 
32e2299
fe25e4b
32e2299
8baf1dd
 
32e2299
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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)