Added demo webhook poster

This commit is contained in:
Joe Keen 2015-07-31 11:22:39 -06:00
parent 7770f7b9b0
commit 8dc20b2d7d
1 changed files with 21 additions and 0 deletions

21
demo/post_webhook.py Normal file
View File

@ -0,0 +1,21 @@
import json
import requests
import time
address = "localhost/foo"
while True:
t = random.uniform(100, 10000)
body = {'VM Create time': '{}'.format(t),
'units': 'ms'}
headers = {'content-type': 'application/json'}
try:
requests.post(url=address,
data=json.dumps(body),
headers=headers,
timeout="10")
except Exception:
print("unable to post")
time.sleep(random.randint(5, 20))