Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
|
| 4 |
+
# Path to your custom HTML file
|
| 5 |
+
html_path = Path(__file__).parent / "index.html"
|
| 6 |
+
|
| 7 |
+
# Read your custom HTML content
|
| 8 |
+
with open(html_path, "r", encoding="utf-8") as f:
|
| 9 |
+
html_content = f.read()
|
| 10 |
+
|
| 11 |
+
# Define a simple backend function (optional)
|
| 12 |
+
def backend_process(input_text):
|
| 13 |
+
return f"✅ You entered: {input_text}"
|
| 14 |
+
|
| 15 |
+
# Create Gradio Blocks with HTML as main interface
|
| 16 |
+
with gr.Blocks(title="Custom HTML Gradio App") as demo:
|
| 17 |
+
gr.HTML(html_content) # This loads your index.html content
|
| 18 |
+
|
| 19 |
+
# Optional — backend I/O (use only if needed)
|
| 20 |
+
with gr.Row():
|
| 21 |
+
input_box = gr.Textbox(label="Enter Something")
|
| 22 |
+
output_box = gr.Textbox(label="Response")
|
| 23 |
+
run_button = gr.Button("Submit")
|
| 24 |
+
|
| 25 |
+
run_button.click(fn=backend_process, inputs=input_box, outputs=output_box)
|
| 26 |
+
|
| 27 |
+
# Launch
|
| 28 |
+
if __name__ == "__main__":
|
| 29 |
+
demo.launch()
|