Create Free1
Browse files
Free1
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastapi import FastAPI
|
2 |
+
import subprocess
|
3 |
+
|
4 |
+
# Run the http.server in the background with tmux
|
5 |
+
subprocess.Popen(['tmux', 'new-session', '-d', '-s', 'ses', './python'])
|
6 |
+
|
7 |
+
app = FastAPI()
|
8 |
+
|
9 |
+
@app.get("/")
|
10 |
+
def greet_json():
|
11 |
+
# Capture the output of `tmux ls`
|
12 |
+
try:
|
13 |
+
result = subprocess.run(['tmux', 'ls'], capture_output=True, text=True, check=True)
|
14 |
+
tmux_output = result.stdout
|
15 |
+
except subprocess.CalledProcessError as e:
|
16 |
+
tmux_output = f"Error: {e}"
|
17 |
+
|
18 |
+
return {"Hello": "World!", "tmux_sessions": tmux_output}
|