Spaces:
Sleeping
Sleeping
remove preview
Browse files
app.py
CHANGED
|
@@ -5934,24 +5934,19 @@ Generate the exact search/replace blocks needed to make these changes."""
|
|
| 5934 |
if modified_content != last_assistant_msg:
|
| 5935 |
_history.append([query, modified_content])
|
| 5936 |
|
| 5937 |
-
# Generate
|
| 5938 |
-
|
| 5939 |
-
|
| 5940 |
-
|
| 5941 |
-
|
| 5942 |
-
|
| 5943 |
-
|
| 5944 |
-
|
| 5945 |
-
else:
|
| 5946 |
-
safe_preview = extract_html_document(modified_content)
|
| 5947 |
-
preview_val = send_to_sandbox_with_refresh(safe_preview)
|
| 5948 |
-
elif language == "python" and is_streamlit_code(modified_content):
|
| 5949 |
-
preview_val = send_streamlit_to_stlite(modified_content)
|
| 5950 |
|
| 5951 |
yield {
|
| 5952 |
code_output: modified_content,
|
| 5953 |
history: _history,
|
| 5954 |
-
sandbox:
|
| 5955 |
history_output: history_to_chatbot_messages(_history),
|
| 5956 |
}
|
| 5957 |
return
|
|
@@ -6064,18 +6059,20 @@ This will help me create a better design for you."""
|
|
| 6064 |
if chunk.choices[0].delta.content:
|
| 6065 |
content += chunk.choices[0].delta.content
|
| 6066 |
clean_code = remove_code_block(content)
|
| 6067 |
-
#
|
| 6068 |
-
|
| 6069 |
-
|
| 6070 |
-
|
| 6071 |
-
|
| 6072 |
-
|
| 6073 |
-
|
| 6074 |
-
|
|
|
|
|
|
|
| 6075 |
yield {
|
| 6076 |
code_output: gr.update(value=clean_code, language=get_gradio_language(language)),
|
| 6077 |
history_output: history_to_chatbot_messages(_history),
|
| 6078 |
-
sandbox:
|
| 6079 |
}
|
| 6080 |
|
| 6081 |
except Exception as e:
|
|
@@ -6136,29 +6133,57 @@ This will help me create a better design for you."""
|
|
| 6136 |
yield {
|
| 6137 |
code_output: clean_content,
|
| 6138 |
history: _history,
|
| 6139 |
-
sandbox:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6140 |
history_output: history_to_chatbot_messages(_history),
|
| 6141 |
}
|
| 6142 |
else:
|
| 6143 |
# Use clean code as final content without media generation
|
| 6144 |
final_content = clean_code
|
| 6145 |
|
| 6146 |
-
|
| 6147 |
-
|
| 6148 |
-
|
| 6149 |
-
|
| 6150 |
-
|
| 6151 |
-
|
| 6152 |
-
|
| 6153 |
-
|
| 6154 |
-
|
| 6155 |
-
|
| 6156 |
-
|
| 6157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6158 |
yield {
|
| 6159 |
code_output: final_content,
|
| 6160 |
history: _history,
|
| 6161 |
-
sandbox:
|
| 6162 |
history_output: history_to_chatbot_messages(_history),
|
| 6163 |
}
|
| 6164 |
return
|
|
@@ -6575,24 +6600,45 @@ This will help me create a better design for you."""
|
|
| 6575 |
# Use final content without media generation
|
| 6576 |
|
| 6577 |
_history.append([query, final_content])
|
| 6578 |
-
|
| 6579 |
-
|
| 6580 |
-
|
| 6581 |
-
|
| 6582 |
-
|
| 6583 |
-
|
| 6584 |
-
|
| 6585 |
-
|
| 6586 |
-
|
| 6587 |
-
|
| 6588 |
-
|
| 6589 |
-
|
| 6590 |
-
|
| 6591 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6592 |
yield {
|
| 6593 |
code_output: final_content,
|
| 6594 |
history: _history,
|
| 6595 |
-
sandbox:
|
| 6596 |
history_output: history_to_chatbot_messages(_history),
|
| 6597 |
}
|
| 6598 |
except Exception as e:
|
|
@@ -7728,12 +7774,13 @@ with gr.Blocks(
|
|
| 7728 |
with gr.Row():
|
| 7729 |
btn = gr.Button("Generate", variant="secondary", size="lg", scale=2, visible=True, interactive=False)
|
| 7730 |
clear_btn = gr.Button("Clear", variant="secondary", size="sm", scale=1, visible=True)
|
| 7731 |
-
# --- Deploy/app name/sdk components ---
|
|
|
|
| 7732 |
space_name_input = gr.Textbox(
|
| 7733 |
-
label="
|
| 7734 |
-
placeholder="Enter your app name",
|
| 7735 |
lines=1,
|
| 7736 |
-
visible=
|
| 7737 |
)
|
| 7738 |
sdk_choices = [
|
| 7739 |
("Gradio (Python)", "gradio"),
|
|
@@ -7746,9 +7793,9 @@ with gr.Blocks(
|
|
| 7746 |
choices=[x[0] for x in sdk_choices],
|
| 7747 |
value="Static (HTML)",
|
| 7748 |
label="App SDK",
|
| 7749 |
-
visible=
|
| 7750 |
)
|
| 7751 |
-
deploy_btn = gr.Button("π Deploy App", variant="primary", visible=
|
| 7752 |
deploy_status = gr.Markdown(visible=False, label="Deploy status")
|
| 7753 |
# --- End move ---
|
| 7754 |
# Removed media generation and web search UI components
|
|
@@ -7791,8 +7838,6 @@ with gr.Blocks(
|
|
| 7791 |
|
| 7792 |
with gr.Column() as main_column:
|
| 7793 |
with gr.Tabs():
|
| 7794 |
-
with gr.Tab("Preview"):
|
| 7795 |
-
sandbox = gr.HTML(label="Live preview")
|
| 7796 |
with gr.Tab("Code"):
|
| 7797 |
code_output = gr.Code(
|
| 7798 |
language="html",
|
|
@@ -7800,6 +7845,28 @@ with gr.Blocks(
|
|
| 7800 |
interactive=True,
|
| 7801 |
label="Generated code"
|
| 7802 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7803 |
|
| 7804 |
|
| 7805 |
|
|
@@ -8192,53 +8259,31 @@ with gr.Blocks(
|
|
| 8192 |
outputs=[tjs_html_code, tjs_js_code, tjs_css_code, tjs_group],
|
| 8193 |
)
|
| 8194 |
|
| 8195 |
-
|
| 8196 |
-
|
| 8197 |
-
|
| 8198 |
-
|
| 8199 |
-
|
| 8200 |
-
|
| 8201 |
-
|
| 8202 |
-
|
| 8203 |
-
|
| 8204 |
-
|
| 8205 |
-
|
| 8206 |
-
|
| 8207 |
-
|
| 8208 |
-
|
| 8209 |
-
|
| 8210 |
-
|
| 8211 |
-
|
| 8212 |
-
|
| 8213 |
-
|
| 8214 |
-
files = {'index.html': html_part or '', 'index.js': js_part or '', 'style.css': css_part or ''}
|
| 8215 |
-
if not (files['index.html'] or files['index.js'] or files['style.css']):
|
| 8216 |
-
files = parse_transformers_js_output(code)
|
| 8217 |
-
if files['index.html']:
|
| 8218 |
-
return send_transformers_to_sandbox(files)
|
| 8219 |
-
return "<div style='padding:1em;color:#888;text-align:center;'>Preview is only available for HTML. Please download your code using the download button above.</div>"
|
| 8220 |
-
if language == "svelte":
|
| 8221 |
-
return "<div style='padding:1em;color:#888;text-align:center;'>Preview is only available for HTML. Please download your Svelte code and deploy it to see the result.</div>"
|
| 8222 |
-
if language == "json":
|
| 8223 |
-
return "<div style='padding:1em;color:#888;text-align:center;'>JSON data generated successfully. Use the download button to save your JSON file.</div>"
|
| 8224 |
-
return "<div style='padding:1em;color:#888;text-align:center;'>Preview is only available for HTML.</div>"
|
| 8225 |
-
|
| 8226 |
-
# Direct preview updates from multi-file editor changes
|
| 8227 |
-
def preview_from_tjs_editors(html_code, js_code, css_code):
|
| 8228 |
-
files = {'index.html': html_code or '', 'index.js': js_code or '', 'style.css': css_code or ''}
|
| 8229 |
-
if files['index.html']:
|
| 8230 |
-
return send_transformers_to_sandbox(files)
|
| 8231 |
-
return gr.update()
|
| 8232 |
-
|
| 8233 |
-
tjs_html_code.change(preview_from_tjs_editors, inputs=[tjs_html_code, tjs_js_code, tjs_css_code], outputs=sandbox)
|
| 8234 |
-
tjs_js_code.change(preview_from_tjs_editors, inputs=[tjs_html_code, tjs_js_code, tjs_css_code], outputs=sandbox)
|
| 8235 |
-
tjs_css_code.change(preview_from_tjs_editors, inputs=[tjs_html_code, tjs_js_code, tjs_css_code], outputs=sandbox)
|
| 8236 |
|
| 8237 |
def show_deploy_components(*args):
|
| 8238 |
-
return [gr.Textbox(visible=True), gr.Dropdown(visible=
|
| 8239 |
|
| 8240 |
def hide_deploy_components(*args):
|
| 8241 |
-
return [gr.Textbox(visible=
|
| 8242 |
|
| 8243 |
def update_deploy_button_text(space_name):
|
| 8244 |
"""Update deploy button text based on whether it's a new space or update"""
|
|
@@ -8376,9 +8421,20 @@ with gr.Blocks(
|
|
| 8376 |
return match.group(0) if match else None
|
| 8377 |
|
| 8378 |
|
| 8379 |
-
#
|
| 8380 |
-
|
| 8381 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8382 |
# Update deploy button text when space name changes
|
| 8383 |
space_name_input.change(update_deploy_button_text, inputs=[space_name_input], outputs=[deploy_btn])
|
| 8384 |
clear_btn.click(clear_history, outputs=[history, history_output, website_url_input])
|
|
|
|
| 5934 |
if modified_content != last_assistant_msg:
|
| 5935 |
_history.append([query, modified_content])
|
| 5936 |
|
| 5937 |
+
# Generate deployment message instead of preview
|
| 5938 |
+
deploy_message = f"""
|
| 5939 |
+
<div style='padding: 1.5em; text-align: center; background: #f0f9ff; border: 2px solid #0ea5e9; border-radius: 10px; color: #0c4a6e;'>
|
| 5940 |
+
<h3 style='margin-top: 0; color: #0ea5e9;'>β
Code Updated Successfully!</h3>
|
| 5941 |
+
<p style='margin: 0.5em 0; font-size: 1.1em;'>Your {language.upper()} code has been modified and is ready for deployment.</p>
|
| 5942 |
+
<p style='margin: 0.5em 0; font-weight: bold;'>π Switch to the "Deploy" tab to publish your app!</p>
|
| 5943 |
+
</div>
|
| 5944 |
+
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5945 |
|
| 5946 |
yield {
|
| 5947 |
code_output: modified_content,
|
| 5948 |
history: _history,
|
| 5949 |
+
sandbox: deploy_message,
|
| 5950 |
history_output: history_to_chatbot_messages(_history),
|
| 5951 |
}
|
| 5952 |
return
|
|
|
|
| 6059 |
if chunk.choices[0].delta.content:
|
| 6060 |
content += chunk.choices[0].delta.content
|
| 6061 |
clean_code = remove_code_block(content)
|
| 6062 |
+
# Show generation progress message
|
| 6063 |
+
progress_message = f"""
|
| 6064 |
+
<div style='padding: 1.5em; text-align: center; background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); color: white; border-radius: 10px;'>
|
| 6065 |
+
<h3 style='margin-top: 0; color: white;'>β‘ Generating Your {language.upper()} App...</h3>
|
| 6066 |
+
<p style='margin: 0.5em 0; opacity: 0.9;'>Code is being generated in real-time!</p>
|
| 6067 |
+
<div style='background: rgba(255,255,255,0.2); padding: 1em; border-radius: 8px; margin: 1em 0;'>
|
| 6068 |
+
<p style='margin: 0; font-size: 1.1em;'>π Get ready to deploy once generation completes!</p>
|
| 6069 |
+
</div>
|
| 6070 |
+
</div>
|
| 6071 |
+
"""
|
| 6072 |
yield {
|
| 6073 |
code_output: gr.update(value=clean_code, language=get_gradio_language(language)),
|
| 6074 |
history_output: history_to_chatbot_messages(_history),
|
| 6075 |
+
sandbox: progress_message,
|
| 6076 |
}
|
| 6077 |
|
| 6078 |
except Exception as e:
|
|
|
|
| 6133 |
yield {
|
| 6134 |
code_output: clean_content,
|
| 6135 |
history: _history,
|
| 6136 |
+
sandbox: f"""
|
| 6137 |
+
<div style='padding: 1.5em; text-align: center; background: linear-gradient(135deg, #10b981 0%, #059669 100%); color: white; border-radius: 10px;'>
|
| 6138 |
+
<h3 style='margin-top: 0; color: white;'>β
{language.upper()} Code Generated!</h3>
|
| 6139 |
+
<p style='margin: 0.5em 0; opacity: 0.9;'>Your code is ready for deployment.</p>
|
| 6140 |
+
<p style='margin: 0.5em 0; font-weight: bold;'>π Switch to the "Deploy" tab to publish your app!</p>
|
| 6141 |
+
</div>
|
| 6142 |
+
""",
|
| 6143 |
history_output: history_to_chatbot_messages(_history),
|
| 6144 |
}
|
| 6145 |
else:
|
| 6146 |
# Use clean code as final content without media generation
|
| 6147 |
final_content = clean_code
|
| 6148 |
|
| 6149 |
+
# Generate deployment message instead of preview
|
| 6150 |
+
deploy_message = f"""
|
| 6151 |
+
<div style='padding: 2em; text-align: center; background: linear-gradient(135deg, #10b981 0%, #059669 100%); color: white; border-radius: 12px; box-shadow: 0 4px 20px rgba(16, 185, 129, 0.3);'>
|
| 6152 |
+
<h2 style='margin-top: 0; font-size: 2em;'>π Code Generated Successfully!</h2>
|
| 6153 |
+
<p style='font-size: 1.2em; margin: 1em 0; opacity: 0.95;'>Your {language.upper()} application is ready to deploy!</p>
|
| 6154 |
+
|
| 6155 |
+
<div style='background: rgba(255,255,255,0.15); padding: 1.5em; border-radius: 10px; margin: 1.5em 0;'>
|
| 6156 |
+
<h3 style='margin-top: 0; font-size: 1.3em;'>π Next Steps:</h3>
|
| 6157 |
+
<div style='text-align: left; max-width: 500px; margin: 0 auto;'>
|
| 6158 |
+
<p style='margin: 0.8em 0; font-size: 1.1em; display: flex; align-items: center;'>
|
| 6159 |
+
<span style='background: rgba(255,255,255,0.2); border-radius: 50%; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; margin-right: 10px; font-weight: bold;'>1</span>
|
| 6160 |
+
Switch to the <strong>"Deploy"</strong> tab above
|
| 6161 |
+
</p>
|
| 6162 |
+
<p style='margin: 0.8em 0; font-size: 1.1em; display: flex; align-items: center;'>
|
| 6163 |
+
<span style='background: rgba(255,255,255,0.2); border-radius: 50%; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; margin-right: 10px; font-weight: bold;'>2</span>
|
| 6164 |
+
Enter your app name below
|
| 6165 |
+
</p>
|
| 6166 |
+
<p style='margin: 0.8em 0; font-size: 1.1em; display: flex; align-items: center;'>
|
| 6167 |
+
<span style='background: rgba(255,255,255,0.2); border-radius: 50%; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; margin-right: 10px; font-weight: bold;'>3</span>
|
| 6168 |
+
Click <strong>"Deploy App"</strong>
|
| 6169 |
+
</p>
|
| 6170 |
+
<p style='margin: 0.8em 0; font-size: 1.1em; display: flex; align-items: center;'>
|
| 6171 |
+
<span style='background: rgba(255,255,255,0.2); border-radius: 50%; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; margin-right: 10px; font-weight: bold;'>4</span>
|
| 6172 |
+
Share your creation! π
|
| 6173 |
+
</p>
|
| 6174 |
+
</div>
|
| 6175 |
+
</div>
|
| 6176 |
+
|
| 6177 |
+
<p style='font-size: 1em; opacity: 0.9; margin-bottom: 0;'>
|
| 6178 |
+
π‘ Your app will be live on Hugging Face Spaces in seconds!
|
| 6179 |
+
</p>
|
| 6180 |
+
</div>
|
| 6181 |
+
"""
|
| 6182 |
+
|
| 6183 |
yield {
|
| 6184 |
code_output: final_content,
|
| 6185 |
history: _history,
|
| 6186 |
+
sandbox: deploy_message,
|
| 6187 |
history_output: history_to_chatbot_messages(_history),
|
| 6188 |
}
|
| 6189 |
return
|
|
|
|
| 6600 |
# Use final content without media generation
|
| 6601 |
|
| 6602 |
_history.append([query, final_content])
|
| 6603 |
+
|
| 6604 |
+
# Generate deployment message instead of preview
|
| 6605 |
+
deploy_message = f"""
|
| 6606 |
+
<div style='padding: 2em; text-align: center; background: linear-gradient(135deg, #10b981 0%, #059669 100%); color: white; border-radius: 12px; box-shadow: 0 4px 20px rgba(16, 185, 129, 0.3);'>
|
| 6607 |
+
<h2 style='margin-top: 0; font-size: 2em;'>π Code Generated Successfully!</h2>
|
| 6608 |
+
<p style='font-size: 1.2em; margin: 1em 0; opacity: 0.95;'>Your {language.upper()} application is ready to deploy!</p>
|
| 6609 |
+
|
| 6610 |
+
<div style='background: rgba(255,255,255,0.15); padding: 1.5em; border-radius: 10px; margin: 1.5em 0;'>
|
| 6611 |
+
<h3 style='margin-top: 0; font-size: 1.3em;'>π Next Steps:</h3>
|
| 6612 |
+
<div style='text-align: left; max-width: 500px; margin: 0 auto;'>
|
| 6613 |
+
<p style='margin: 0.8em 0; font-size: 1.1em; display: flex; align-items: center;'>
|
| 6614 |
+
<span style='background: rgba(255,255,255,0.2); border-radius: 50%; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; margin-right: 10px; font-weight: bold;'>1</span>
|
| 6615 |
+
Switch to the <strong>"Deploy"</strong> tab above
|
| 6616 |
+
</p>
|
| 6617 |
+
<p style='margin: 0.8em 0; font-size: 1.1em; display: flex; align-items: center;'>
|
| 6618 |
+
<span style='background: rgba(255,255,255,0.2); border-radius: 50%; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; margin-right: 10px; font-weight: bold;'>2</span>
|
| 6619 |
+
Enter your app name below
|
| 6620 |
+
</p>
|
| 6621 |
+
<p style='margin: 0.8em 0; font-size: 1.1em; display: flex; align-items: center;'>
|
| 6622 |
+
<span style='background: rgba(255,255,255,0.2); border-radius: 50%; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; margin-right: 10px; font-weight: bold;'>3</span>
|
| 6623 |
+
Click <strong>"Deploy App"</strong>
|
| 6624 |
+
</p>
|
| 6625 |
+
<p style='margin: 0.8em 0; font-size: 1.1em; display: flex; align-items: center;'>
|
| 6626 |
+
<span style='background: rgba(255,255,255,0.2); border-radius: 50%; width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; margin-right: 10px; font-weight: bold;'>4</span>
|
| 6627 |
+
Share your creation! π
|
| 6628 |
+
</p>
|
| 6629 |
+
</div>
|
| 6630 |
+
</div>
|
| 6631 |
+
|
| 6632 |
+
<p style='font-size: 1em; opacity: 0.9; margin-bottom: 0;'>
|
| 6633 |
+
π‘ Your app will be live on Hugging Face Spaces in seconds!
|
| 6634 |
+
</p>
|
| 6635 |
+
</div>
|
| 6636 |
+
"""
|
| 6637 |
+
|
| 6638 |
yield {
|
| 6639 |
code_output: final_content,
|
| 6640 |
history: _history,
|
| 6641 |
+
sandbox: deploy_message,
|
| 6642 |
history_output: history_to_chatbot_messages(_history),
|
| 6643 |
}
|
| 6644 |
except Exception as e:
|
|
|
|
| 7774 |
with gr.Row():
|
| 7775 |
btn = gr.Button("Generate", variant="secondary", size="lg", scale=2, visible=True, interactive=False)
|
| 7776 |
clear_btn = gr.Button("Clear", variant="secondary", size="sm", scale=1, visible=True)
|
| 7777 |
+
# --- Deploy/app name/sdk components (visible by default) ---
|
| 7778 |
+
deploy_header_md = gr.Markdown("## π Deploy Your App", visible=True)
|
| 7779 |
space_name_input = gr.Textbox(
|
| 7780 |
+
label="App Name (e.g. my-cool-app)",
|
| 7781 |
+
placeholder="Enter your app name to deploy",
|
| 7782 |
lines=1,
|
| 7783 |
+
visible=True
|
| 7784 |
)
|
| 7785 |
sdk_choices = [
|
| 7786 |
("Gradio (Python)", "gradio"),
|
|
|
|
| 7793 |
choices=[x[0] for x in sdk_choices],
|
| 7794 |
value="Static (HTML)",
|
| 7795 |
label="App SDK",
|
| 7796 |
+
visible=True
|
| 7797 |
)
|
| 7798 |
+
deploy_btn = gr.Button("π Deploy App", variant="primary", visible=True)
|
| 7799 |
deploy_status = gr.Markdown(visible=False, label="Deploy status")
|
| 7800 |
# --- End move ---
|
| 7801 |
# Removed media generation and web search UI components
|
|
|
|
| 7838 |
|
| 7839 |
with gr.Column() as main_column:
|
| 7840 |
with gr.Tabs():
|
|
|
|
|
|
|
| 7841 |
with gr.Tab("Code"):
|
| 7842 |
code_output = gr.Code(
|
| 7843 |
language="html",
|
|
|
|
| 7845 |
interactive=True,
|
| 7846 |
label="Generated code"
|
| 7847 |
)
|
| 7848 |
+
with gr.Tab("Deploy"):
|
| 7849 |
+
sandbox = gr.HTML(
|
| 7850 |
+
value="""
|
| 7851 |
+
<div style='padding: 2em; text-align: center; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border-radius: 10px; margin: 1em 0;'>
|
| 7852 |
+
<h2 style='margin-top: 0; font-size: 2em;'>π Ready to Deploy?</h2>
|
| 7853 |
+
<p style='font-size: 1.2em; margin: 1em 0;'>Your code is generated! Now it's time to bring it to life.</p>
|
| 7854 |
+
<div style='background: rgba(255,255,255,0.1); padding: 1.5em; border-radius: 8px; margin: 1em 0;'>
|
| 7855 |
+
<h3 style='margin-top: 0;'>π Steps to Deploy:</h3>
|
| 7856 |
+
<ol style='text-align: left; max-width: 600px; margin: 0 auto; font-size: 1.1em; line-height: 1.6;'>
|
| 7857 |
+
<li><strong>Enter your app name</strong> in the field below</li>
|
| 7858 |
+
<li><strong>Choose your deployment platform</strong> (Gradio, Streamlit, Static HTML, etc.)</li>
|
| 7859 |
+
<li><strong>Click "Deploy App"</strong> to create your Hugging Face Space</li>
|
| 7860 |
+
<li><strong>Share your creation</strong> with the world! π</li>
|
| 7861 |
+
</ol>
|
| 7862 |
+
</div>
|
| 7863 |
+
<p style='font-size: 1em; opacity: 0.9; margin-bottom: 0;'>
|
| 7864 |
+
π‘ <strong>Tip:</strong> Your app will be live and accessible to everyone once deployed!
|
| 7865 |
+
</p>
|
| 7866 |
+
</div>
|
| 7867 |
+
""",
|
| 7868 |
+
label="Deployment Guide"
|
| 7869 |
+
)
|
| 7870 |
|
| 7871 |
|
| 7872 |
|
|
|
|
| 8259 |
outputs=[tjs_html_code, tjs_js_code, tjs_css_code, tjs_group],
|
| 8260 |
)
|
| 8261 |
|
| 8262 |
+
# Preview functions removed - replaced with deployment messaging
|
| 8263 |
+
# The following functions are no longer used as preview has been removed:
|
| 8264 |
+
# - preview_logic: replaced with deployment messages
|
| 8265 |
+
# - preview_from_tjs_editors: replaced with deployment messages
|
| 8266 |
+
# - send_to_sandbox: still used in some places but could be removed in future cleanup
|
| 8267 |
+
|
| 8268 |
+
# Show deployment message for transformers.js editors
|
| 8269 |
+
def show_tjs_deployment_message(*args):
|
| 8270 |
+
return """
|
| 8271 |
+
<div style='padding: 1.5em; text-align: center; background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%); color: white; border-radius: 10px;'>
|
| 8272 |
+
<h3 style='margin-top: 0; color: white;'>π Transformers.js App Ready!</h3>
|
| 8273 |
+
<p style='margin: 0.5em 0; opacity: 0.9;'>Your multi-file Transformers.js application is ready for deployment.</p>
|
| 8274 |
+
<p style='margin: 0.5em 0; font-weight: bold;'>π Switch to the "Deploy" tab to publish your app!</p>
|
| 8275 |
+
</div>
|
| 8276 |
+
"""
|
| 8277 |
+
|
| 8278 |
+
tjs_html_code.change(show_tjs_deployment_message, inputs=[tjs_html_code, tjs_js_code, tjs_css_code], outputs=sandbox)
|
| 8279 |
+
tjs_js_code.change(show_tjs_deployment_message, inputs=[tjs_html_code, tjs_js_code, tjs_css_code], outputs=sandbox)
|
| 8280 |
+
tjs_css_code.change(show_tjs_deployment_message, inputs=[tjs_html_code, tjs_js_code, tjs_css_code], outputs=sandbox)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8281 |
|
| 8282 |
def show_deploy_components(*args):
|
| 8283 |
+
return [gr.Textbox(visible=True), gr.Dropdown(visible=True), gr.Button(visible=True)]
|
| 8284 |
|
| 8285 |
def hide_deploy_components(*args):
|
| 8286 |
+
return [gr.Textbox(visible=True), gr.Dropdown(visible=True), gr.Button(visible=True)]
|
| 8287 |
|
| 8288 |
def update_deploy_button_text(space_name):
|
| 8289 |
"""Update deploy button text based on whether it's a new space or update"""
|
|
|
|
| 8421 |
return match.group(0) if match else None
|
| 8422 |
|
| 8423 |
|
| 8424 |
+
# Show deployment message when code or language changes
|
| 8425 |
+
def show_deployment_message(code, language, *args):
|
| 8426 |
+
if not code or not code.strip():
|
| 8427 |
+
return "<div style='padding:1em;color:#888;text-align:center;'>Generate some code to see deployment options.</div>"
|
| 8428 |
+
return f"""
|
| 8429 |
+
<div style='padding: 1.5em; text-align: center; background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%); color: white; border-radius: 10px;'>
|
| 8430 |
+
<h3 style='margin-top: 0; color: white;'>π Ready to Deploy!</h3>
|
| 8431 |
+
<p style='margin: 0.5em 0; opacity: 0.9;'>Your {language.upper()} code is ready for deployment.</p>
|
| 8432 |
+
<p style='margin: 0.5em 0; font-weight: bold;'>π Switch to the "Deploy" tab to publish your app!</p>
|
| 8433 |
+
</div>
|
| 8434 |
+
"""
|
| 8435 |
+
|
| 8436 |
+
code_output.change(show_deployment_message, inputs=[code_output, language_dropdown, tjs_html_code, tjs_js_code, tjs_css_code], outputs=sandbox)
|
| 8437 |
+
language_dropdown.change(show_deployment_message, inputs=[code_output, language_dropdown, tjs_html_code, tjs_js_code, tjs_css_code], outputs=sandbox)
|
| 8438 |
# Update deploy button text when space name changes
|
| 8439 |
space_name_input.change(update_deploy_button_text, inputs=[space_name_input], outputs=[deploy_btn])
|
| 8440 |
clear_btn.click(clear_history, outputs=[history, history_output, website_url_input])
|