Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def run_get():
- url = 'https://api.github.com/users/runnable'
- # this issues a GET to the url. replace "get" with "post", "head",
- # "put", "patch"... to make a request using a different method
- r = requests.get(url)
- return json.dumps(r.json(), indent=4)
- @app.route('/run_post')
- def run_post():
- url = 'http://httpbin.org/post'
- data = {'a': 10, 'b': [{'c': True, 'd': False}, None]}
- headers = {'Content-Type': 'application/json'}
- r = requests.post(url, data=json.dumps(data), headers=headers)
- return json.dumps(r.json(), indent=4)
Advertisement
Add Comment
Please, Sign In to add comment