-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrtdfs.py
More file actions
29 lines (23 loc) · 710 Bytes
/
rtdfs.py
File metadata and controls
29 lines (23 loc) · 710 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import requests
import time
import random
from datetime import datetime, timezone, timedelta
URL = "http://(((url)))/sendData"
def generate_data_unit():
utc_plus_3 = timezone(timedelta(hours=3))
return {
"ID": "Data-flow-simulation-1",
"sID": 0,
"dt": datetime.now(utc_plus_3).isoformat(),
"d": random.uniform(-10, 10)
}
while True:
payload = {
"AllCurrentData": [generate_data_unit()]
}
try:
response = requests.post(URL, json=payload)
print(f"[{datetime.now().isoformat()}] Status: {response.status_code}, Response: {response.text}")
except Exception as e:
print(f"Error sending data: {e}")
time.sleep(5)