MCPJ / app.py
Techbitforge's picture
Update app.py
1c22605 verified
raw
history blame
2.01 kB
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)