Skip to content

Instantly share code, notes, and snippets.

@MarchLiu
Created July 28, 2013 17:17
Show Gist options
  • Save MarchLiu/6099328 to your computer and use it in GitHub Desktop.
Save MarchLiu/6099328 to your computer and use it in GitHub Desktop.
how to put a http request in python code
import urllib2
opener = urllib2.build_opener(urllib2.HTTPHandler)
with open("/storage/pic/logo.png") as f:
data=f.read()
request = urllib2.Request("http://localhost:8080/logo.png", data=data)
request.add_header("Content-Type", "image/png")
request.get_method = lambda:"PUT"
url = opener.open(request)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment