from flask import Flask, request from datetime import date import os app = Flask(__name__) ip_addresses = {"187.144.10.199":[date.today()],"187.144.103.54":[date.today()],"187.144.121.210":[date.today()],"187.144.34.230":[date.today()],"187.144.46.100":[date.today()],"187.144.62.186":[date.today()],"187.144.78.121":[date.today()],"201.175.204.74":[date.today()],"209.52.88.22":[date.today()],"24.69.148.186":[date.today()]} @app.route("/api") def ip_tracker(): if request.headers.getlist("X-Forwarded-For"): ip = request.headers.getlist("X-Forwarded-For")[0] else: ip = request.remote_addr visits = ip_addresses.get(ip) if visits == None: ip_addresses[ip] = [date.today()] else: today = date.today() if today not in ip_addresses[ip]: ip_addresses[ip].append(today) return { "length": len(ip_addresses), "data": ip_addresses, "user": ip }