Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- from time import gmtime, strftime, sleep
- import random
- def main():
- i = 0
- while i < 10000:
- r = requests.post('http://localhost:8080/sensorthings/v1.0/Observations',
- data = { "phenomenonTime": strftime("%Y-%m-%dT%H:%M:%S.000Z", gmtime()),
- "resultTime": strftime("%Y-%m-%dT%H:%M:%S.000Z", gmtime()),
- "result": random.uniform(0.0, 50.0),
- "Datastream": {"@iot.id": 1},
- "FeatureOfInterest": {"@iot.id": 1 } })
- r2 = requests.post('http://localhost:8080/sensorthings/v1.0/Observations',
- data = { "phenomenonTime": strftime("%Y-%m-%dT%H:%M:%S.000Z", gmtime()),
- "resultTime": strftime("%Y-%m-%dT%H:%M:%S.000Z", gmtime()),
- "result": random.uniform(1000, 1000000),
- "Datastream": {"@iot.id": 2},
- "FeatureOfInterest": {"@iot.id": 1 } })
- r3 = requests.post('http://localhost:8080/sensorthings/v1.0/Observations',
- data = { "phenomenonTime": strftime("%Y-%m-%dT%H:%M:%S.000Z", gmtime()),
- "resultTime": strftime("%Y-%m-%dT%H:%M:%S.000Z", gmtime()),
- "result": random.uniform(1000, 100000),
- "Datastream": {"@iot.id": 3},
- "FeatureOfInterest": {"@iot.id": 1 } })
- r4 = requests.post('http://localhost:8080/sensorthings/v1.0/Observations',
- data = { "phenomenonTime": strftime("%Y-%m-%dT%H:%M:%S.000Z", gmtime()),
- "resultTime": strftime("%Y-%m-%dT%H:%M:%S.000Z", gmtime()),
- "result": random.uniform(800, 1050),
- "Datastream": {"@iot.id": 4},
- "FeatureOfInterest": {"@iot.id": 1 } })
- r5 = requests.post('http://localhost:8080/sensorthings/v1.0/Observations',
- data = { "phenomenonTime": strftime("%Y-%m-%dT%H:%M:%S.000Z", gmtime()),
- "resultTime": strftime("%Y-%m-%dT%H:%M:%S.000Z", gmtime()),
- "result": random.uniform(30, 100),
- "Datastream": {"@iot.id": 5},
- "FeatureOfInterest": {"@iot.id": 1 } })
- print(r.status_code)
- print(r2.status_code)
- print(r3.status_code)
- print(r4.status_code)
- print(r5.status_code)
- sleep(2)
- i += 1
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement