
from flask import Flask, json, jsonify, logging

app = Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello, World!'

@app.route('/v3/scene/ip_reputation', methods=['GET'])
def get_data():
    from flask import request
    resource = request.args.get('resource', '')
    print(f"resource: {resource}")
    # Example data similar to your JSON structure
    data = {
        "data": [
            {
                "ioc": "159.203.93.255",
                "host": "10.65.135.204",
                "intelligence": [
                    {
                        "judgments": ["Exploit", "Spam", "Phishing", "DDoS", "APT"],
                        "severity": "low",
                        "ban": {
                            "banned": 1,
                            "reason": "The IP address belongs to DigitalOcean, LLC, it is recommended to assess and handle it accordingly."
                        },
                        "basic": {
                            "carrier": "DigitalOcean, LLC",
                            "location": {
                                "country": "美国",
                                "country_code": "US",
                                "province": "新泽西州",
                                "city": "克利夫顿",
                                "lng": -74.16366,
                                "lat": 40.858402
                            }
                        },
                        "asn": {
                            "number": "14061",
                            "info": "DIGITALOCEAN-ASN - DigitalOcean, LLC, US"
                        },
                        "tags_classes": {
                            "virus_family": [
                                "Mirai"
                            ],
                            "industry": [
                                "internet"
                            ],
                            "gangs": [
                                "APT"
                            ],
                            "tags": [
                                "APT",
                                "海莲花"
                            ],
                            "tags_type": [
                                "industry"
                            ]
                        },
                        "scene": "Residence",
                        "ioc_type": "ipv4",
                        "confidence_level": "low",
                        "is_malicious": True,
                        "source_name": "微步在线-IP信誉",
                        "update_time": 1719268503000
                    }
                ]
            }
        ],
        "response_code": 0,
        "verbose_msg": "success"
    }
    # Read JSON data from file
    with open('data/data.json', 'r', encoding='utf-8') as f:
        data = json.load(f)
        
    return jsonify(data)

if __name__ == '__main__':
    app.run(debug=True, port=8080)