Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -16,7 +16,6 @@ def run_python(code):
|
|
| 16 |
|
| 17 |
# Web runner (HTML/CSS/JS)
|
| 18 |
def run_web(code):
|
| 19 |
-
# Display in iframe so code is rendered properly
|
| 20 |
return f'<iframe style="width:100%; height:100%; border:none; border-radius:8px; background:#1e1e1e;" srcdoc="{code}"></iframe>'
|
| 21 |
|
| 22 |
# Main runner
|
|
@@ -46,22 +45,18 @@ h1 { color:#D16BA5; text-align:center; }
|
|
| 46 |
</html>"""
|
| 47 |
|
| 48 |
with gr.Blocks(css="""
|
| 49 |
-
/* Global Dark Theme */
|
| 50 |
body { margin:0; padding:0; font-family:'Poppins', sans-serif; background:#121212; color:#e0e0e0; }
|
| 51 |
-
header { background:#000000; padding:16px; color:#D16BA5; font-size:1.8em; text-align:center; }
|
| 52 |
.gradio-container { max-width:1200px; margin:auto; padding:20px; }
|
| 53 |
.gr-row { display:flex; gap:20px; margin-top:20px; }
|
| 54 |
.output-panel { flex:1; background:#1e1e1e; border-radius:8px; box-shadow:0 4px 8px rgba(0,0,0,0.5); height:500px; padding:16px; font-family: monospace; color: #00ff00; white-space: pre-wrap; overflow:auto; }
|
| 55 |
.gr-textbox textarea { font-family: monospace; background:#1e1e1e; color:#e0e0e0; border:none; border-radius:8px; padding:16px; height:500px; overflow:auto; }
|
| 56 |
-
.gr-radio { color:#e0e0e0; margin-
|
| 57 |
button, .gr-button { background-color:#D16BA5 !important; color:#fff !important; border-radius:6px !important; padding:10px 20px !important; }
|
| 58 |
footer { display:none !important; } /* Hide Gradio footer */
|
|
|
|
| 59 |
""") as demo:
|
| 60 |
|
| 61 |
-
#
|
| 62 |
-
gr.Markdown("<header>Fun Code Playground – Powered by Simple & Static</header>")
|
| 63 |
-
|
| 64 |
-
# Language selector
|
| 65 |
lang_selector = gr.Radio(
|
| 66 |
choices=["Python", "Web (HTML/CSS/JS)"],
|
| 67 |
value="Web (HTML/CSS/JS)",
|
|
@@ -82,6 +77,9 @@ footer { display:none !important; } /* Hide Gradio footer */
|
|
| 82 |
# Render button
|
| 83 |
render_button = gr.Button("Render")
|
| 84 |
|
|
|
|
|
|
|
|
|
|
| 85 |
# Update starter template on language change
|
| 86 |
def update_template(lang):
|
| 87 |
return starter_python if lang == "Python" else starter_web
|
|
|
|
| 16 |
|
| 17 |
# Web runner (HTML/CSS/JS)
|
| 18 |
def run_web(code):
|
|
|
|
| 19 |
return f'<iframe style="width:100%; height:100%; border:none; border-radius:8px; background:#1e1e1e;" srcdoc="{code}"></iframe>'
|
| 20 |
|
| 21 |
# Main runner
|
|
|
|
| 45 |
</html>"""
|
| 46 |
|
| 47 |
with gr.Blocks(css="""
|
|
|
|
| 48 |
body { margin:0; padding:0; font-family:'Poppins', sans-serif; background:#121212; color:#e0e0e0; }
|
|
|
|
| 49 |
.gradio-container { max-width:1200px; margin:auto; padding:20px; }
|
| 50 |
.gr-row { display:flex; gap:20px; margin-top:20px; }
|
| 51 |
.output-panel { flex:1; background:#1e1e1e; border-radius:8px; box-shadow:0 4px 8px rgba(0,0,0,0.5); height:500px; padding:16px; font-family: monospace; color: #00ff00; white-space: pre-wrap; overflow:auto; }
|
| 52 |
.gr-textbox textarea { font-family: monospace; background:#1e1e1e; color:#e0e0e0; border:none; border-radius:8px; padding:16px; height:500px; overflow:auto; }
|
| 53 |
+
.gr-radio { color:#e0e0e0; margin-bottom:16px; }
|
| 54 |
button, .gr-button { background-color:#D16BA5 !important; color:#fff !important; border-radius:6px !important; padding:10px 20px !important; }
|
| 55 |
footer { display:none !important; } /* Hide Gradio footer */
|
| 56 |
+
header { background:#000000; padding:16px; color:#D16BA5; font-size:1.8em; text-align:center; margin-top:20px; }
|
| 57 |
""") as demo:
|
| 58 |
|
| 59 |
+
# Language selector at the top
|
|
|
|
|
|
|
|
|
|
| 60 |
lang_selector = gr.Radio(
|
| 61 |
choices=["Python", "Web (HTML/CSS/JS)"],
|
| 62 |
value="Web (HTML/CSS/JS)",
|
|
|
|
| 77 |
# Render button
|
| 78 |
render_button = gr.Button("Render")
|
| 79 |
|
| 80 |
+
# Footer-style header at the bottom
|
| 81 |
+
gr.Markdown("<header>Fun Code Playground – Powered by Simple & Static</header>")
|
| 82 |
+
|
| 83 |
# Update starter template on language change
|
| 84 |
def update_template(lang):
|
| 85 |
return starter_python if lang == "Python" else starter_web
|