Spaces:
Runtime error
Runtime error
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 PufferPanel v2.7.1 (latest stable release) | |
subprocess.run( | |
"wget https://github.com/PufferPanel/PufferPanel/releases/download/v2.7.1/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, check=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 thread | |
threading.Thread(target=run_pufferpanel, daemon=True).start() | |
# ================================ | |
# Gradio Wrapper App | |
# ================================ | |
def launch_info(): | |
return """ | |
# β PufferPanel is running inside Hugging Face | |
Use the embedded panel 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) |