Simulate graph states in the browser

randomize.py 559B

12345678910111213141516171819202122232425262728
  1. """
  2. Makes a dummy post to the test server
  3. """
  4. import requests
  5. import json
  6. import abp
  7. import random
  8. import time
  9. #URL = "http://localhost:5000"
  10. URL = "https://abv.peteshadbolt.co.uk/"
  11. def test_graph():
  12. N = 50
  13. g = abp.NXGraphState(range(N))
  14. for i in range(N):
  15. g.act_cz(random.randint(0, N-1), random.randint(0, N-1))
  16. g.layout()
  17. return g
  18. if __name__ == '__main__':
  19. while True:
  20. data = json.dumps(test_graph().to_json(stringify=False))
  21. r = requests.post("{}/graph".format(URL), data=data)
  22. time.sleep(5)