This script needs to be passed to mitmdump, for example:
mitmdump -s xkcd_sub.py -p 8080
You'll then need to redirect browsers to this http proxy port. If you want other people to enjoy the same experience, why not try arp spoorfing, rogue DHCP serving, or wpad :)