restart / app.py
davanstrien's picture
davanstrien HF Staff
Refactor app.py to use gr.Blocks for displaying time
f1028c7
raw
history blame
521 Bytes
import gradio as gr
from datetime import datetime
from apscheduler.schedulers.background import BackgroundScheduler
from huggingface_hub import restart_space
import os
HF_TOKEN = os.getenv("HF_TOKEN")
time_start = datetime.now()
def restart():
gr.Info("Restarting space...")
restart_space("davanstrien/restart", token=HF_TOKEN)
with gr.Blocks() as demo:
gr.Markdown(f"Time started: {time_start}")
demo.launch()
scheduler = BackgroundScheduler()
job = scheduler.add_job(restart, "interval", minutes=2)