Skip to content
This repository has been archived by the owner on Feb 6, 2021. It is now read-only.

Latest commit

 

History

History
47 lines (35 loc) · 850 Bytes

README.rst

File metadata and controls

47 lines (35 loc) · 850 Bytes

urlfetch

Description

An easy to use HTTP client.

Installation

$ pip install urlfetch -U

Hello World

from urlfetch import get

response = get('http://python.org/')
print response.body

Upload file

from urlfetch import post

response = post(
    'http://127.0.0.1:8888/upload', 
    headers = {
        'Referer': 'http://127.0.0.1/',
    },
    files = {
        'fieldname1': open('/path/to/file', 'rb'),
        #'fieldname2': 'file content', # file must have a filename
        'fieldname3': ('filename', open('/path/to/file2', 'rb')),
        'fieldname4': ('filename', 'file content'),
    },
    data = {
        'foo': 'bar'
    },
)

print response.status, response.body