Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,15 @@
|
|
1 |
import os
|
2 |
import subprocess
|
|
|
|
|
|
|
3 |
|
4 |
-
#
|
5 |
-
# Install PufferPanel
|
6 |
-
#
|
7 |
def install_pufferpanel():
|
8 |
if not os.path.exists("pufferpanel"):
|
9 |
-
# Download latest
|
10 |
subprocess.run(
|
11 |
"wget https://github.com/PufferPanel/PufferPanel/releases/latest/download/pufferpanel-linux-amd64.tar.gz -O puffer.tar.gz",
|
12 |
shell=True,
|
@@ -15,12 +18,52 @@ def install_pufferpanel():
|
|
15 |
subprocess.run("tar -xzf puffer.tar.gz -C .", shell=True, check=True)
|
16 |
subprocess.run("rm puffer.tar.gz", shell=True)
|
17 |
|
18 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
subprocess.run("./pufferpanel install --user admin --password admin123", shell=True, check=True)
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
install_pufferpanel()
|
22 |
|
23 |
-
#
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import os
|
2 |
import subprocess
|
3 |
+
import threading
|
4 |
+
import json
|
5 |
+
import gradio as gr
|
6 |
|
7 |
+
# ================================
|
8 |
+
# Install & Configure PufferPanel
|
9 |
+
# ================================
|
10 |
def install_pufferpanel():
|
11 |
if not os.path.exists("pufferpanel"):
|
12 |
+
# Download latest release
|
13 |
subprocess.run(
|
14 |
"wget https://github.com/PufferPanel/PufferPanel/releases/latest/download/pufferpanel-linux-amd64.tar.gz -O puffer.tar.gz",
|
15 |
shell=True,
|
|
|
18 |
subprocess.run("tar -xzf puffer.tar.gz -C .", shell=True, check=True)
|
19 |
subprocess.run("rm puffer.tar.gz", shell=True)
|
20 |
|
21 |
+
# Configure PufferPanel to run on port 8080
|
22 |
+
config = {
|
23 |
+
"web": {"listen": "0.0.0.0:8080"},
|
24 |
+
"daemon": {"listen": "0.0.0.0:5657"}
|
25 |
+
}
|
26 |
+
with open("config.json", "w") as f:
|
27 |
+
json.dump(config, f, indent=4)
|
28 |
+
|
29 |
+
# Initialize admin user
|
30 |
subprocess.run("./pufferpanel install --user admin --password admin123", shell=True, check=True)
|
31 |
|
32 |
+
# ================================
|
33 |
+
# Run PufferPanel in background
|
34 |
+
# ================================
|
35 |
+
def run_pufferpanel():
|
36 |
+
subprocess.run("./pufferpanel run", shell=True)
|
37 |
+
|
38 |
+
# Ensure installation
|
39 |
install_pufferpanel()
|
40 |
|
41 |
+
# Start PufferPanel in background
|
42 |
+
threading.Thread(target=run_pufferpanel, daemon=True).start()
|
43 |
+
|
44 |
+
# ================================
|
45 |
+
# Gradio App (Wrapper UI)
|
46 |
+
# ================================
|
47 |
+
def launch_info():
|
48 |
+
return """
|
49 |
+
# ✅ PufferPanel is running inside this Hugging Face Space
|
50 |
+
|
51 |
+
Use the embedded dashboard below.
|
52 |
+
**Login Credentials:**
|
53 |
+
- **User:** `admin`
|
54 |
+
- **Pass:** `admin123`
|
55 |
+
"""
|
56 |
+
|
57 |
+
with gr.Blocks(title="PufferPanel on Hugging Face") as demo:
|
58 |
+
gr.Markdown(launch_info)
|
59 |
+
gr.HTML(
|
60 |
+
"""
|
61 |
+
<iframe src="http://localhost:8080"
|
62 |
+
style="width:100%; height:800px; border:none;">
|
63 |
+
</iframe>
|
64 |
+
"""
|
65 |
+
)
|
66 |
+
|
67 |
+
if __name__ == "__main__":
|
68 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|
69 |
+
|