akhaliq HF Staff commited on
Commit
cd2bdda
·
1 Parent(s): 9fb4088
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -1084,8 +1084,16 @@ This will help me create a better design for you."""
1084
  # Deploy to Spaces logic
1085
 
1086
  def wrap_html_in_gradio_app(html_code):
1087
- # Minimal Gradio app that serves the HTML code
1088
- return f'''import gradio as gr\n\ndef show_html():\n return """{html_code.replace('"', '\\"').replace("'", "\\'")}"""\n\ndemo = gr.Interface(fn=show_html, inputs=None, outputs=gr.HTML())\n\nif __name__ == "__main__":\n demo.launch()\n'''
 
 
 
 
 
 
 
 
1089
 
1090
  def deploy_to_spaces(code):
1091
  if not code or not code.strip():
 
1084
  # Deploy to Spaces logic
1085
 
1086
  def wrap_html_in_gradio_app(html_code):
1087
+ # Escape triple quotes for safe embedding
1088
+ safe_html = html_code.replace('"""', r'\"\"\"')
1089
+ return (
1090
+ 'import gradio as gr\n\n'
1091
+ 'def show_html():\n'
1092
+ f' return """{safe_html}"""\n\n'
1093
+ 'demo = gr.Interface(fn=show_html, inputs=None, outputs=gr.HTML())\n\n'
1094
+ 'if __name__ == "__main__":\n'
1095
+ ' demo.launch()\n'
1096
+ )
1097
 
1098
  def deploy_to_spaces(code):
1099
  if not code or not code.strip():