Created
July 28, 2013 17:17
-
-
Save MarchLiu/6099328 to your computer and use it in GitHub Desktop.
how to put a http request in python code
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
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