2
0

dashing-interface.py 630 B

12345678910111213141516171819202122232425262728
  1. #!/usr/bin/python
  2. import json
  3. import requests
  4. class DashingAdapter:
  5. base_url = None
  6. def __init__(self, base_url, auth_token):
  7. self.base_url = base_url
  8. self.auth_token = auth_token
  9. def send(self, metric, current, previous=None, blubb=None, bla=None):
  10. info = {
  11. 'auth_token': self.auth_token,
  12. 'current': int(current),
  13. }
  14. if not previous is None:
  15. info['previous'] = previous
  16. url = self.base_url + metric
  17. r = requests.post(url, data=json.dumps(info))
  18. return r
  19. if __name__ == "__main__":
  20. d = DashingAdapter('http://dashing.krombel.de:3030/widgets/', 'bitnhmlj47hamrftxkiug')
  21. d.send('testNumber', 42)