File size: 1,045 Bytes
c52de80 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
import requests
import time
import threading
import gradio as gr
url = "https://laravel-s7t0.onrender.com"
logs = []
# Ping function running in background
def ping_loop():
while True:
try:
response = requests.get(url)
log_entry = f"Pinged {url} | Status code: {response.status_code}"
except Exception as e:
log_entry = f"Error pinging {url}: {e}"
print(log_entry)
logs.append(log_entry)
# Keep only last 50 logs for display
if len(logs) > 50:
logs.pop(0)
time.sleep(40)
# Start ping in background thread
threading.Thread(target=ping_loop, daemon=True).start()
# GUI function
def get_logs():
return "\n".join(logs)
# Gradio interface
with gr.Blocks() as demo:
gr.Markdown("## Render Ping Monitor")
log_box = gr.Textbox(label="Ping Logs", value="", interactive=False, lines=20)
refresh_btn = gr.Button("Refresh Logs")
refresh_btn.click(get_logs, None, log_box)
demo.launch(server_name="0.0.0.0", server_port=7860) |