updaTE
This commit is contained in:
parent
a039517975
commit
5b5325f2f6
@ -160,4 +160,6 @@
|
||||
2021-04-22 10:15:53.540044 -> Warning: Address(host='192.168.1.99', port=43642) created new sensor.
|
||||
SENSOR: name='test1' value='juhuu'
|
||||
2021-04-22 10:16:02.865022 -> Warning: Address(host='192.168.1.99', port=43644) created new sensor.
|
||||
SENSOR: name='test2' value='eeeh'
|
||||
SENSOR: name='test2' value='eeeh'
|
||||
2021-04-23 11:22:54.684617 -> Warning: 192.168.1.231 disconnected/is not available
|
||||
2021-04-23 11:36:58.295015 -> Warning: 192.168.1.231 disconnected/is not available
|
@ -239,12 +239,20 @@ def admin_get(command: str):
|
||||
return filesystem
|
||||
|
||||
|
||||
@app.post("/admin/upload_file")
|
||||
async def create_upload_file(uploaded_file: UploadFile = File(...), patch: str = ""):
|
||||
@app.post("/admin/{id_server}/upload_file")
|
||||
async def create_upload_file(id_server: int, uploaded_file: UploadFile = File(...), patch: str = ""):
|
||||
file_location = f"{patch}{uploaded_file.filename}"
|
||||
with open(file_location, "wb+") as file_object:
|
||||
file_object.write(uploaded_file.file.read())
|
||||
return {"info": f"file '{uploaded_file.filename}' saved at '{file_location}'"}
|
||||
if id_server == ID:
|
||||
with open(file_location, "wb+") as file_object:
|
||||
file_object.write(uploaded_file.file.read())
|
||||
else:
|
||||
with open(f"cache/{uploaded_file.filename}", "wb+") as file_object:
|
||||
file_object.write(uploaded_file.file.read())
|
||||
file = open(f"cache/{uploaded_file.filename}", "r")
|
||||
requests.post(f"""http://{heartbeat_table["IP"][heartbeat_table["ID"].index(id_server)]}:8000/admin/{id_server}/upload_file""",
|
||||
files={"uploaded_file": file, "patch": patch})
|
||||
file.close()
|
||||
return {"info": f"""file '{uploaded_file.filename}' saved at '{id_server}/{file_location}'"""}
|
||||
|
||||
|
||||
# Todo upload of update file and settings
|
||||
|
@ -1,9 +1,6 @@
|
||||
import requests
|
||||
import time
|
||||
send_n = 100
|
||||
wait_t = 0.5
|
||||
|
||||
for x in range(send_n):
|
||||
r = requests.post("http://192.168.1.99:8000/messages/post", json={"m_sender": "server", "message": str(x)})
|
||||
print(f"Sent message {x+1}/{send_n}\nResponse: {r.text}")
|
||||
time.sleep(wait_t)
|
||||
file = open("files/test.jpg", "r")
|
||||
r = requests.post(f"""http://192.168.1.99:8000/admin/1/upload_file""",
|
||||
files={"uploaded_file": file, "patch": ""})
|
||||
print(r.text)
|
Loading…
Reference in New Issue
Block a user