Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,7 +6,7 @@ from datetime import datetime
|
|
6 |
|
7 |
app = Flask(__name__)
|
8 |
execution_logs = []
|
9 |
-
MAX_LOG_ENTRIES =
|
10 |
|
11 |
def run_cli_script():
|
12 |
"""Runs cli.py and streams logs in real-time to both UI and terminal."""
|
@@ -17,7 +17,7 @@ def run_cli_script():
|
|
17 |
process = subprocess.Popen(
|
18 |
["python", "cli.py"],
|
19 |
stdout=subprocess.PIPE,
|
20 |
-
stderr=subprocess.
|
21 |
text=True,
|
22 |
bufsize=1
|
23 |
)
|
@@ -35,7 +35,8 @@ def run_cli_script():
|
|
35 |
execution_logs.append({'time': timestamp, 'output': '', 'error': line})
|
36 |
print(line, end="") # ✅ Print errors to terminal
|
37 |
if len(execution_logs) > MAX_LOG_ENTRIES:
|
38 |
-
execution_logs
|
|
|
39 |
|
40 |
except Exception as e:
|
41 |
log_entry['error'] = str(e)
|
|
|
6 |
|
7 |
app = Flask(__name__)
|
8 |
execution_logs = []
|
9 |
+
MAX_LOG_ENTRIES = 1000
|
10 |
|
11 |
def run_cli_script():
|
12 |
"""Runs cli.py and streams logs in real-time to both UI and terminal."""
|
|
|
17 |
process = subprocess.Popen(
|
18 |
["python", "cli.py"],
|
19 |
stdout=subprocess.PIPE,
|
20 |
+
stderr=subprocess.STDOUT,
|
21 |
text=True,
|
22 |
bufsize=1
|
23 |
)
|
|
|
35 |
execution_logs.append({'time': timestamp, 'output': '', 'error': line})
|
36 |
print(line, end="") # ✅ Print errors to terminal
|
37 |
if len(execution_logs) > MAX_LOG_ENTRIES:
|
38 |
+
execution_logs = execution_logs[-MAX_LOG_ENTRIES:] # Keep only the latest logs
|
39 |
+
|
40 |
|
41 |
except Exception as e:
|
42 |
log_entry['error'] = str(e)
|