#!/usr/bin/env python3
"""Minimal HTTP server for the Storage Access bubble TOCTOU POC.

Serves victim.html and evil.html on 127.0.0.1:23987. Chrome is launched with
--host-resolver-rules so that victim.test and evil.test both resolve here.
"""
import http.server
import os
import socketserver

PORT = 23987
ROOT = os.path.dirname(os.path.abspath(__file__))
os.chdir(ROOT)


class Handler(http.server.SimpleHTTPRequestHandler):
    def end_headers(self):
        self.send_header('Cache-Control', 'no-store')
        super().end_headers()


if __name__ == '__main__':
    socketserver.TCPServer.allow_reuse_address = True
    with socketserver.TCPServer(('127.0.0.1', PORT), Handler) as httpd:
        print(f'serving {ROOT} on http://127.0.0.1:{PORT}/', flush=True)
        httpd.serve_forever()
