Team Ai
Apppublic

Stryker-SC/Discord-Bot-VCMaster-JavaScript-Revamped

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes
app.py38 linesDownload Raw Back to root
1import os2import subprocess3import spaces4import gradio as gr5 6# Hugging Face ZeroGPU requires a Gradio app with a registered GPU function.7# We create a minimal UI and a dummy GPU function to pass the security check.8@spaces.GPU9def _dummy_gpu_function():10    return "ZeroGPU check passed!"11 12with gr.Blocks() as demo:13    gr.Markdown("# VC Master")14    gr.Markdown("The Discord bot is running in the background.")15    btn = gr.Button("Test ZeroGPU")16    out = gr.Textbox()17    btn.click(fn=_dummy_gpu_function, outputs=out)18 19# Define the portable Node.js binary URL20NODE_URL = "https://nodejs.org/dist/v22.13.0/node-v22.13.0-linux-x64.tar.xz"21NODE_DIR = "node-v22.13.0-linux-x64"22 23# Download and extract the portable installation24if not os.path.exists(NODE_DIR):25    print("Downloading portable Node.js binary...")26    os.system(f"wget -qO- {NODE_URL} | tar -xJ")27 28# Inject the portable Node.js into the container's environment path29os.environ["PATH"] = os.path.abspath(f"{NODE_DIR}/bin") + os.pathsep + os.environ["PATH"]30 31# Boot the Node.js bot in a detached background process32print("Booting VC Master in background...")33os.system("npm install")34subprocess.Popen(["node", "index.js"])35 36# Launch the Gradio app to satisfy Hugging Face's router and claim port 786037demo.launch()38