Created
May 20, 2014 15:53
-
-
Save rmca/5fc7feb596d7b4e579ff to your computer and use it in GitHub Desktop.
This file contains 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 requests | |
render_url = "http://example.com/render/" | |
target = 'your.metric.name.here' | |
from = '00:00_20140101' | |
until = '23:59_20140520' | |
# First omit the format so the request will render as PNG (default) | |
post_dict = {'from': from, 'until': until, 'target': target} | |
r = requests.post(render_url, data=post_dict) | |
# Now request JSON format. No matter what we request now it will come back with the previous response, | |
# for every method other than GET (assuming the cache is cold). | |
post_dict = {'from': from, 'until': until, 'target': target, 'format': 'json'} | |
s = requests.post(render_url, data=post_dict) | |
# Check what the content-type was. For buggy installs this should be image/png. | |
print s.headers['content-type'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment