Skip to content

Instantly share code, notes, and snippets.

@karteek
Created April 19, 2011 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save karteek/927153 to your computer and use it in GitHub Desktop.
Save karteek/927153 to your computer and use it in GitHub Desktop.
Gist for replacing an image using Squid
#!/usr/bin/env python
import sys
def is_logo(url):
# This logo1w.png can change each day
if url.endswith('logo1w.png'):
return True
else:
return False
while True:
input_line = sys.stdin.readline().strip()
url = input_line.split(' ')[0]
if is_logo(url):
new_url = 'http://path.to.localserver/images/ashok.png\n'
else:
new_url = url + '\n'
# Do note that new_url should end with a \n
sys.stdout.write(new_url)
sys.stdout.flush()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment