diff --git a/cpu-bench/bench.py b/cpu-bench/bench.py old mode 100755 new mode 100644 diff --git a/playwright/mitm.py b/playwright/mitm.py new file mode 100644 index 0000000..204bafb --- /dev/null +++ b/playwright/mitm.py @@ -0,0 +1,21 @@ +from mitmproxy import http +import redis, json, base64 +r = redis.Redis('192.168.12.2') + +def response(flow: http.HTTPFlow) -> None: + # if not flow.request.url.endswith('.webp'): + # return + if not (200 <= flow.response.status_code < 300): + return + + response_data = { + "status_code": flow.response.status_code, + "headers": dict(flow.response.headers), + "content": base64.b64encode(flow.response.content).decode('utf-8') + } + # JSON 문자열로 변환 + response_json = json.dumps(response_data) + + # Redis에 저장 + r.hset('static', flow.request.url, response_json) + print(f"Cached response for {flow.request.url}") \ No newline at end of file