FN_scrapping / app.py
BarngSJ
ew
34d098b
raw
history blame
877 Bytes
import streamlit as st
import schedule
import time
import subprocess
import threading
# Function to execute your scripts
def job():
st.write("Running scheduled scripts...")
subprocess.run(["python", "scrap_data_from_FN.py"])
time.sleep(20)
subprocess.run(["python", "run_at_morning.py"])
st.write("Scripts executed successfully!")
# Schedule the job at 04:00 AM daily
schedule.every().day.at("04:00").do(job)
# Background scheduler function
def run_scheduler():
while True:
schedule.run_pending()
time.sleep(60)
# Start the scheduler in a separate thread
threading.Thread(target=run_scheduler, daemon=True).start()
# Streamlit UI
st.title("Automated Script Runner on Hugging Face Spaces")
st.write("This app automatically runs scripts at 04:00 AM.")
if st.button("Run Now"):
job()
st.success("Scripts executed manually!")