restart / app.py
davanstrien's picture
davanstrien HF Staff
Add gradio functionality and dependencies
89ea3f0
raw
history blame
574 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 show_time():
return f"Time started: {time_start}"
def restart():
gr.Info("Restarting space...")
restart_space("davanstrien/restart", token=HF_TOKEN)
iface = gr.Interface(fn=show_time, inputs="text", outputs="text")
iface.launch()
scheduler = BackgroundScheduler()
job = scheduler.add_job(restart, "interval", minutes=2)