Created
May 24, 2018 17:44
-
-
Save fser/6410b9899dc0f4c8c74b37f5e7231f36 to your computer and use it in GitHub Desktop.
Chronomètre le temps de réponse pour une requête HTTP et affiche le header `X-Backend-Server`
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
#!/usr/bin/env python | |
import requests | |
import sys | |
from timeit import default_timer as timer | |
def get_page(url): | |
r = requests.get(url) | |
return r.headers.get('X-Backend-Server', 'No backend returned') | |
if __name__ == '__main__': | |
if len(sys.argv) != 2: | |
print "%s: URL" % (sys.argv[0]) | |
sys.exit (1) | |
start = timer() | |
backend = get_page(sys.argv[1]) | |
end = timer() | |
print "{} responded in {}s".format(backend, (end - start)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment