User:Inge Hoonte/operating system detector: Difference between revisions

From XPUB & Lens-Based wiki
(Created page with "<source lang="bash"> #!/usr/bin/python import os print "Content-type: image/jpg" print if "Linux" in os.environ['HTTP_USER_AGENT']: f=open("linux.jpg") print f...")
(No difference)

Revision as of 01:46, 4 November 2011

#!/usr/bin/python

import os
print "Content-type: image/jpg"
print

if "Linux" in os.environ['HTTP_USER_AGENT']:
        f=open("linux.jpg")
        print f.read()

elif "Mac" in os.environ['HTTP_USER_AGENT']:
        f=open("mac.jpg")
        print f.read()

elif "Windows" in os.environ['HTTP_USER_AGENT']:
        f=open("windows.jpg")
        print f.read()