Created
March 14, 2020 18:50
-
-
Save tsengia/ea2fde9fd23019896eaeeac8f9d923e6 to your computer and use it in GitHub Desktop.
Simple keep alive python3 script that makes a HTTP request every 2 minutes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import urllib.request | |
# Sleep for 2 minutes before sending the next keep alive | |
# This value is in seconds | |
DELAY = 120 | |
# Url that we will be requesting. | |
URL = "https://example.com" | |
# NOTE: I dont know if caching will become a problem, if it does, trying mixing up the URL... | |
# Send the keep alive request to Google | |
def doKeepAlive(): | |
global URL | |
contents = urllib.request.urlopen(URL).read() | |
print("PING") | |
while True: | |
doKeepAlive() | |
time.sleep(DELAY) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment