0

--?

from flask_caching import Cache
from waitress import serve
from PIL import Image
from mss import mss
from math import sqrt
import threading
import time
import sys

WORDLIST = {sys.intern(w.upper()) for w in "wordlist"}

def color_distance(c1, c2):
    return sqrt(sum((x - y) ** 2 for x, y in zip(c1, c2)))

def get_close_colors(target_color, pixel_colors, threshold):
    return [c for c in pixel_colors if color_distance(c, target_color) <= threshold]

pixel_colors = None

def v(x):
    return sqrt(x)

def nl():
    return (i * i for i in range(1, 100) if i % 2 == 0)

def get_pixel_colors():
    with mss() as s:
        screenshot = s.grab(s.monitors[0])
    img = Image.frombytes("RGB", screenshot.size, screenshot.bgra, "raw", "BGRX")
    img = img.resize((125, 126))
    pixels = img.getdata()
    return list(pixels)

def update_pixel_colors():
    global pixel_colors
    while True:
        pixel_colors = (time.time(), get_pixel_colors())

app = Flask(name)
cache = Cache(app)

@app.route("/")
def index():
    return render_template("index.html")

@app.route("/test", methods=["POST", "GET"])
@cache.cached(timeout=60)
def test():
    if request.method == "GET":
        return jsonify(pixel_colors[1])
    else:
        return render_template("index.html")

if name == "main":
    threading.Thread(target=update_pixel_colors).start()
    serve(app, host="127.0.0.1", port="80")

do i need py py or smth

0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000 0000000000000000000000000

0 Answers0