Spaces:
Running on Zero
Running on Zero
File size: 713 Bytes
ddd8dda 2003ad1 02a9e83 18e322a ddd8dda 2003ad1 02a9e83 47bd0ff 2003ad1 18e322a 6203ebe ddb3e40 2003ad1 20e8798 6203ebe 2003ad1 3ee12ea 2003ad1 | 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 | import os
import sys
import gradio as gr
import spaces
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "src"))
from backend.main import app as fastapi_app
@spaces.GPU
def fake_gpu():
pass
with gr.Blocks() as demo:
gr.Markdown("BrainBox Backend is Running natively inside Gradio!")
btn = gr.Button("ZeroGPU Keepalive")
btn.click(fn=fake_gpu, inputs=[], outputs=[])
original_init = gr.routes.App.__init__
def custom_init(self, *args, **kwargs):
original_init(self, *args, **kwargs)
self.mount("/api", fastapi_app)
gr.routes.App.__init__ = custom_init
if __name__ == "__main__":
demo.launch(server_name="0.0.0.0", server_port=int(os.environ.get("PORT", "7860")))
|