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