Skip to content

Commit

Permalink
add main.y
Browse files Browse the repository at this point in the history
  • Loading branch information
jian-en committed Jul 17, 2016
1 parent e3aa955 commit 45f53f7
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions ch3/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ def request_method():


def params_request():
response = requests.get(build_uri('users'), params={'since': 135})
response = requests.get(build_uri('users'), params={'since': 11})
print better_print(response.text)
print response.request.headers
print response.url


def json_request():
# response = requests.patch(build_uri('user'), auth=('imoocdemo', 'imoocdemo123'), data={'name': 'babymooc1', 'email': 'helloworld@imooc.org'})
response = requests.delete(build_uri('user/emails'), auth=('imoocdemo', 'imoocdemo123'), json=['hello@github.com'])
# response = requests.patch(build_uri('user'), auth=('imoocdemo', 'imoocdemo123'), json={'name': 'babymooc2', 'email': 'hello-world@imooc.org'})
response = requests.post(build_uri('user/emails'), auth=('imoocdemo', 'imoocdemo123'), json=['helloworld@github.com'])
print better_print(response.text)
print response.request.headers
print response.request.body
Expand All @@ -43,9 +45,10 @@ def timeout_request():
print e.message
else:
print response.text
print response.status_code


def hard_request():
def hard_requests():
from requests import Request, Session
s = Session()
headers = {'User-Agent': 'fake1.3.4'}
Expand All @@ -59,6 +62,5 @@ def hard_request():
print resp.request.headers
print resp.text


if __name__ == '__main__':
hard_request()
hard_requests()

0 comments on commit 45f53f7

Please sign in to comment.