Sending
parent
1d5578aafb
commit
c0be695c2f
|
|
@ -0,0 +1,82 @@
|
||||||
|
import sys
|
||||||
|
import threading
|
||||||
|
import time
|
||||||
|
import requests
|
||||||
|
from PyQt6.QtWidgets import (
|
||||||
|
QApplication, QWidget, QVBoxLayout, QLabel,
|
||||||
|
QLineEdit, QPushButton, QMessageBox
|
||||||
|
)
|
||||||
|
from PyQt6.QtCore import QTimer
|
||||||
|
|
||||||
|
class PosterApp(QWidget):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.setWindowTitle("Auto Poster")
|
||||||
|
self.setFixedSize(300, 250)
|
||||||
|
|
||||||
|
self.layout = QVBoxLayout()
|
||||||
|
|
||||||
|
self.ip_label = QLabel("IP Address:")
|
||||||
|
self.ip_input = QLineEdit()
|
||||||
|
self.layout.addWidget(self.ip_label)
|
||||||
|
self.layout.addWidget(self.ip_input)
|
||||||
|
|
||||||
|
self.name_label = QLabel("Name:")
|
||||||
|
self.name_input = QLineEdit()
|
||||||
|
self.layout.addWidget(self.name_label)
|
||||||
|
self.layout.addWidget(self.name_input)
|
||||||
|
|
||||||
|
self.seconds_label = QLabel("Seconds Interval:")
|
||||||
|
self.seconds_input = QLineEdit()
|
||||||
|
self.seconds_input.setText("10")
|
||||||
|
self.layout.addWidget(self.seconds_label)
|
||||||
|
self.layout.addWidget(self.seconds_input)
|
||||||
|
|
||||||
|
self.start_button = QPushButton("Start")
|
||||||
|
self.stop_button = QPushButton("Stop")
|
||||||
|
self.layout.addWidget(self.start_button)
|
||||||
|
self.layout.addWidget(self.stop_button)
|
||||||
|
|
||||||
|
self.setLayout(self.layout)
|
||||||
|
|
||||||
|
self.running = False
|
||||||
|
self.thread = None
|
||||||
|
|
||||||
|
self.start_button.clicked.connect(self.start_posting)
|
||||||
|
self.stop_button.clicked.connect(self.stop_posting)
|
||||||
|
|
||||||
|
def start_posting(self):
|
||||||
|
if self.running:
|
||||||
|
return
|
||||||
|
|
||||||
|
ip = self.ip_input.text().strip()
|
||||||
|
name = self.name_input.text().strip()
|
||||||
|
seconds = self.seconds_input.text().strip()
|
||||||
|
|
||||||
|
if not ip or not name or not seconds.isdigit():
|
||||||
|
QMessageBox.warning(self, "Invalid Input", "Please provide valid IP, name, and seconds.")
|
||||||
|
return
|
||||||
|
|
||||||
|
self.running = True
|
||||||
|
self.thread = threading.Thread(target=self.post_loop, args=(ip, name, int(seconds)), daemon=True)
|
||||||
|
self.thread.start()
|
||||||
|
|
||||||
|
def stop_posting(self):
|
||||||
|
self.running = False
|
||||||
|
|
||||||
|
def post_loop(self, ip, name, seconds):
|
||||||
|
url = f"http://{ip}/{name}/"
|
||||||
|
while self.running:
|
||||||
|
try:
|
||||||
|
print(f"POST to {url}")
|
||||||
|
response = requests.post(url)
|
||||||
|
print(f"Status: {response.status_code}")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error: {e}")
|
||||||
|
time.sleep(seconds)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
app = QApplication(sys.argv)
|
||||||
|
window = PosterApp()
|
||||||
|
window.show()
|
||||||
|
sys.exit(app.exec())
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
# keepalive_daemon.py
|
||||||
|
import time
|
||||||
|
import requests
|
||||||
|
|
||||||
|
IP = "47.21.28.174:5050"
|
||||||
|
NAME = "TEST-daemon"
|
||||||
|
INTERVAL = 10 # seconds
|
||||||
|
|
||||||
|
def main():
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
url = f"http://{IP}/{NAME}/"
|
||||||
|
print(f"POST to {url}")
|
||||||
|
requests.post(url)
|
||||||
|
except Exception as e:
|
||||||
|
print("Error:", e)
|
||||||
|
time.sleep(INTERVAL)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
$CurlArgument = '-X', 'POST',
|
||||||
|
'http://IP:PORT/<LOCATION>/'
|
||||||
|
$CURLEXE = 'curl.exe'
|
||||||
|
& $CURLEXE @CurlArgument
|
||||||
Loading…
Reference in New Issue