from flask import Flask from apscheduler.schedulers.background import BackgroundScheduler import subprocess app = Flask(__name__) def run_cli_script(): """Function to execute the python cli.py command""" print("Running cli.py script...") try: result = subprocess.run(["python", "cli.py"], check=True, capture_output=True, text=True) print("Script output:", result.stdout) except subprocess.CalledProcessError as e: print("Error running script:", e.stderr) # Configure the scheduler scheduler = BackgroundScheduler() scheduler.add_job(run_cli_script, 'interval', hours=3) scheduler.start() @app.route('/') def home(): return "Scheduler is running! The cli.py script will execute every 3 hours." if __name__ == '__main__': app.run(host='0.0.0.0', port=7860)