from pathlib import Path
import html
import gradio as gr
ROOT = Path(__file__).parent.resolve()
def build_iframe() -> str:
document = (ROOT / "index.html").read_text(encoding="utf-8")
document = document.replace('href="/src/styles.css"', 'href="/gradio_api/file=src/styles.css"')
document = document.replace('src="/src/main.js"', 'src="/gradio_api/file=src/main.js"')
srcdoc = html.escape(document, quote=True)
return f"""
"""
css = """
html, body, gradio-app, .gradio-container {
margin: 0 !important;
width: 100% !important;
min-width: 100% !important;
height: 100% !important;
min-height: 100vh !important;
overflow: hidden !important;
background: #030607 !important;
}
.gradio-container {
max-width: none !important;
padding: 0 !important;
}
footer,
.footer {
display: none !important;
}
#splat-frame {
position: fixed !important;
inset: 0 !important;
width: 100vw !important;
height: 100vh !important;
padding: 0 !important;
margin: 0 !important;
}
#splat-frame > div {
padding: 0 !important;
margin: 0 !important;
}
"""
with gr.Blocks(title="Gaussian Splat Walkthrough", fill_height=True, fill_width=True) as demo:
gr.HTML(build_iframe(), elem_id="splat-frame")
if __name__ == "__main__":
demo.launch(allowed_paths=[str(ROOT)], css=css)