Spaces:
Sleeping
Sleeping
Commit ·
b0c681a
1
Parent(s): 0fafc9b
Launch FastAPI server via uvicorn in app.py to keep process alive
Browse files123445673 unmodified lines111213141516171819202122232425262714151630 unmodified lines474849646566676850515270715354555657#!/usr/bin/env python3"""FALL (SwarmNet) - Hugging Face Space Production EntrypointCompatible with ZeroGPU and CPU runtimes.Runs via Uvicorn server on port 7860."""import sysimport os3 unmodified linesROOT_DIR = os.path.abspath(os.path.dirname(__file__))sys.path.insert(0, ROOT_DIR)
# Handle ZeroGPU @spaces.GPU decorator if running under spaces runtimetry: import spaces @spaces.GPU def zerogpu_warmup(): """Satisfies ZeroGPU startup check""" import torch return torch.cuda.is_available() zerogpu_warmup()except Exception: pass
import gradio as gr
# 1. Start Miner 1 (Layers 0 to 14) in backgroundprint("⚡ Starting Swarm Miner 01 (Layers 0-14)...")env = os.environ.copy()30 unmodified lines
time.sleep(2)
# 3. Mount our custom FastAPI app inside Gradiofrom scripts.run_client_ui import app as fastapi_app
# gr.mount_gradio_app modifies and returns the FastAPI appapp = gr.mount_gradio_app(fastapi_app, gr.Blocks(), path="/gradio")# 3. Import and launch the FastAPI app directly with Uvicornfrom scripts.run_client_ui import app
# Export for Hugging Face Spaces Gradio runnerdemo = appif __name__ == "__main__": import uvicorn port = int(os.environ.get("PORT", 7860)) print(f"\n🌐 FALL UI & Swarm Genesis listening on 0.0.0.0:{port}\n") uvicorn.run(app, host="0.0.0.0", port=port, log_level="info")app.py+8-22