25 lines
550 B
Python
25 lines
550 B
Python
import requests
|
|
import logging
|
|
|
|
# Set up optional logging to a file
|
|
logging.basicConfig(
|
|
filename="keepalive.log",
|
|
level=logging.INFO,
|
|
format="%(asctime)s - %(message)s"
|
|
)
|
|
|
|
# Set your target IP and device name
|
|
IP = "0.0.0.0"
|
|
NAME = "test-device"
|
|
|
|
def main():
|
|
try:
|
|
url = f"http://{IP}/{NAME}/"
|
|
response = requests.post(url)
|
|
logging.info(f"POST to {url}, status {response.status_code}")
|
|
except Exception as e:
|
|
logging.error(f"Error sending POST to {url}: {e}")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|