ndurner's picture
make server name and port configurable
b19cc5f
raw
history blame
1.05 kB
from __future__ import annotations
import os
import gradio as gr
import health
from layout import CELL_CSS, wrap_cell
def render_health_panel() -> str:
return wrap_cell(health.render_health_notice())
def create_app() -> gr.Blocks:
"""Create the Gradio application with a minimal notebook-like health cell."""
with gr.Blocks(title="Aileen3 Demo") as demo:
gr.HTML(f"<style>{CELL_CSS}</style>")
health_panel = gr.HTML(value=wrap_cell(health.render_placeholder_notice()))
demo.load(fn=render_health_panel, outputs=health_panel, queue=False)
return demo
def main() -> None:
app = create_app()
server_name = os.environ.get("GRADIO_SERVER_NAME") or os.environ.get("HOST") or "0.0.0.0"
port_value = os.environ.get("GRADIO_SERVER_PORT") or os.environ.get("PORT") or "7860"
try:
server_port = int(port_value)
except ValueError:
server_port = 7860
app.launch(
server_name=server_name,
server_port=server_port,
)
if __name__ == "__main__":
main()