imseldrith commited on
Commit
e96a62a
·
verified ·
1 Parent(s): 926e66c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask
2
+ from apscheduler.schedulers.background import BackgroundScheduler
3
+ import subprocess
4
+
5
+ app = Flask(__name__)
6
+
7
+ def run_cli_script():
8
+ """Function to execute the python cli.py command"""
9
+ print("Running cli.py script...")
10
+ try:
11
+ result = subprocess.run(["python", "cli.py"], check=True, capture_output=True, text=True)
12
+ print("Script output:", result.stdout)
13
+ except subprocess.CalledProcessError as e:
14
+ print("Error running script:", e.stderr)
15
+
16
+ # Configure the scheduler
17
+ scheduler = BackgroundScheduler()
18
+ scheduler.add_job(run_cli_script, 'interval', hours=3)
19
+ scheduler.start()
20
+
21
+ @app.route('/')
22
+ def home():
23
+ return "Scheduler is running! The cli.py script will execute every 3 hours."
24
+
25
+ if __name__ == '__main__':
26
+ app.run(host='0.0.0.0', port=7860)