Update app.py
Browse files
app.py
CHANGED
|
@@ -1,28 +1,21 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from fastapi import FastAPI
|
| 3 |
-
from fastapi.responses import HTMLResponse
|
| 4 |
import os
|
| 5 |
|
| 6 |
-
#
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
# Serve index.html from the current directory
|
| 10 |
-
@app.get("/index.html")
|
| 11 |
-
async def get_index_html():
|
| 12 |
file_path = os.path.join(os.path.dirname(__file__), "index.html")
|
| 13 |
with open(file_path, "r") as f:
|
| 14 |
-
|
| 15 |
-
return HTMLResponse(content=content)
|
| 16 |
|
| 17 |
-
#
|
| 18 |
def embed_html():
|
| 19 |
-
|
| 20 |
-
<
|
| 21 |
-
"""
|
| 22 |
|
| 23 |
-
|
|
|
|
| 24 |
with gr.Tab("Index HTML Tab"):
|
| 25 |
-
gr.HTML(embed_html())
|
| 26 |
|
| 27 |
with gr.Tab("Second Tab"):
|
| 28 |
gr.Textbox(value="Content for the second tab", label="Second Tab Content")
|
|
@@ -30,5 +23,5 @@ with gr.Blocks() as gradio_app:
|
|
| 30 |
with gr.Tab("Third Tab"):
|
| 31 |
gr.Textbox(value="Content for the third tab", label="Third Tab Content")
|
| 32 |
|
| 33 |
-
#
|
| 34 |
-
app
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
| 2 |
import os
|
| 3 |
|
| 4 |
+
# Function to read the content of index.html
|
| 5 |
+
def get_index_html():
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
file_path = os.path.join(os.path.dirname(__file__), "index.html")
|
| 7 |
with open(file_path, "r") as f:
|
| 8 |
+
return f.read()
|
|
|
|
| 9 |
|
| 10 |
+
# Embed the HTML content directly in the Gradio app
|
| 11 |
def embed_html():
|
| 12 |
+
html_content = get_index_html()
|
| 13 |
+
return f"<div style='height: 600px;'>{html_content}</div>"
|
|
|
|
| 14 |
|
| 15 |
+
# Create the Gradio interface with tabs
|
| 16 |
+
with gr.Blocks() as app:
|
| 17 |
with gr.Tab("Index HTML Tab"):
|
| 18 |
+
gr.HTML(embed_html()) # Use gr.HTML to display the HTML content
|
| 19 |
|
| 20 |
with gr.Tab("Second Tab"):
|
| 21 |
gr.Textbox(value="Content for the second tab", label="Second Tab Content")
|
|
|
|
| 23 |
with gr.Tab("Third Tab"):
|
| 24 |
gr.Textbox(value="Content for the third tab", label="Third Tab Content")
|
| 25 |
|
| 26 |
+
# Launch the Gradio app
|
| 27 |
+
app.launch()
|