Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -106,8 +106,8 @@ async def fetch_model_file_content(model_url, file_path):
|
|
106 |
# HTML and JavaScript for the "Copy Code" button
|
107 |
copy_button_html = """
|
108 |
<script>
|
109 |
-
function copyCode() {
|
110 |
-
const text = document.querySelector(
|
111 |
navigator.clipboard.writeText(text).then(() => {
|
112 |
alert("Text copied to clipboard!");
|
113 |
}).catch(() => {
|
@@ -115,7 +115,6 @@ function copyCode() {
|
|
115 |
});
|
116 |
}
|
117 |
</script>
|
118 |
-
<button onclick="copyCode()">Copy Code</button>
|
119 |
"""
|
120 |
|
121 |
# Link to the CSS file
|
@@ -123,6 +122,8 @@ css = "app.css"
|
|
123 |
|
124 |
# Create the Gradio interface
|
125 |
with gr.Blocks(css=css) as demo:
|
|
|
|
|
126 |
with gr.Tabs():
|
127 |
# Tab 1: URL to Text Converter
|
128 |
with gr.Tab("URL to Text Converter"):
|
@@ -137,7 +138,7 @@ with gr.Blocks(css=css) as demo:
|
|
137 |
text_output = gr.Textbox(label="Text Content", interactive=True, elem_id="output-text")
|
138 |
|
139 |
with gr.Row():
|
140 |
-
gr.HTML(
|
141 |
file_output = gr.File(label="Download File", visible=False) # Hidden file download component
|
142 |
|
143 |
submit_button = gr.Button("Fetch Content")
|
@@ -178,10 +179,10 @@ with gr.Blocks(css=css) as demo:
|
|
178 |
file_path_input = gr.Textbox(label="File Path", placeholder="e.g., config.json or README.md")
|
179 |
|
180 |
with gr.Row():
|
181 |
-
model_content_output = gr.Textbox(label="File Content", interactive=True)
|
182 |
|
183 |
with gr.Row():
|
184 |
-
gr.HTML(
|
185 |
|
186 |
submit_model_button = gr.Button("Fetch File Content")
|
187 |
submit_model_button.click(
|
|
|
106 |
# HTML and JavaScript for the "Copy Code" button
|
107 |
copy_button_html = """
|
108 |
<script>
|
109 |
+
function copyCode(textareaId) {
|
110 |
+
const text = document.querySelector(`#${textareaId} textarea`).value;
|
111 |
navigator.clipboard.writeText(text).then(() => {
|
112 |
alert("Text copied to clipboard!");
|
113 |
}).catch(() => {
|
|
|
115 |
});
|
116 |
}
|
117 |
</script>
|
|
|
118 |
"""
|
119 |
|
120 |
# Link to the CSS file
|
|
|
122 |
|
123 |
# Create the Gradio interface
|
124 |
with gr.Blocks(css=css) as demo:
|
125 |
+
gr.HTML(copy_button_html) # Add the "Copy Code" script
|
126 |
+
|
127 |
with gr.Tabs():
|
128 |
# Tab 1: URL to Text Converter
|
129 |
with gr.Tab("URL to Text Converter"):
|
|
|
138 |
text_output = gr.Textbox(label="Text Content", interactive=True, elem_id="output-text")
|
139 |
|
140 |
with gr.Row():
|
141 |
+
gr.HTML("<button onclick='copyCode(\"output-text\")'>Copy Code</button>") # Add the "Copy Code" button
|
142 |
file_output = gr.File(label="Download File", visible=False) # Hidden file download component
|
143 |
|
144 |
submit_button = gr.Button("Fetch Content")
|
|
|
179 |
file_path_input = gr.Textbox(label="File Path", placeholder="e.g., config.json or README.md")
|
180 |
|
181 |
with gr.Row():
|
182 |
+
model_content_output = gr.Textbox(label="File Content", interactive=True, elem_id="model-content-output")
|
183 |
|
184 |
with gr.Row():
|
185 |
+
gr.HTML("<button onclick='copyCode(\"model-content-output\")'>Copy Code</button>") # Add the "Copy Code" button
|
186 |
|
187 |
submit_model_button = gr.Button("Fetch File Content")
|
188 |
submit_model_button.click(
|