This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A simple HTTP proxy which does caching of requests. | |
# Inspired by: https://gist.github.com/bxt/5195500 | |
# but updated for Python 3 and some additional sanity improvements: | |
# - shutil is used to serve files in a streaming manner, so the entire data is not loaded into memory. | |
# - the http request is written to a temp file and renamed on success | |
# - forward headers | |
import http.server | |
import socketserver | |
import urllib.request |