Improve submit script

This commit is contained in:
Midgard 2021-09-19 03:49:00 +02:00
parent 0aece8b8ca
commit bc78ac5775
Signed by: midgard
GPG key ID: 511C112F1331BBB4

13
submit.py Normal file → Executable file
View file

@ -1,10 +1,12 @@
#!/usr/bin/env python3
import os
import json import json
import requests import requests
import time import time
SERVER = os.getenv("LEDSTRIP_SERVER", "http://10.1.0.212:8080")
for i in range(10): for i in range(10):
@ -13,11 +15,12 @@ for i in range(10):
c = codefile.read() c = codefile.read()
except: except:
continue continue
j = {
payload = {
"code": c, "code": c,
"owner": "j", "owner": "j",
"id": i "id": i
} }
r = requests.put('http://10.1.0.212:8080/api/code.json', json=j) r = requests.put(SERVER + '/api/code.json', json=payload)
print(r) print(r)
print(r.text) print(r.text)