Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import
|
| 2 |
import subprocess
|
| 3 |
import tempfile
|
| 4 |
import os
|
|
@@ -41,45 +41,30 @@ def run_pcbasic_code(code, timeout=60):
|
|
| 41 |
except Exception as e:
|
| 42 |
return f"Erro: {str(e)}", None
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
if img:
|
| 49 |
img_byte = io.BytesIO()
|
| 50 |
img.save(img_byte, format="PNG")
|
| 51 |
-
|
| 52 |
-
return text, None
|
| 53 |
|
| 54 |
-
#
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
label="C贸digo BASIC",
|
| 62 |
-
placeholder="Digite seu c贸digo aqui...",
|
| 63 |
-
lines=15
|
| 64 |
-
)
|
| 65 |
-
run_btn = gr.Button("Executar")
|
| 66 |
-
with gr.Column():
|
| 67 |
-
text_out = gr.Textbox(label="Sa铆da de Texto", lines=10)
|
| 68 |
-
image_out = gr.Image(label="Sa铆da Gr谩fica", type="filepath")
|
| 69 |
-
|
| 70 |
-
examples = gr.Examples(
|
| 71 |
-
examples=[
|
| 72 |
-
["10 PRINT \"OL脕 MUNDO!\""],
|
| 73 |
-
["10 FOR I=1 TO 10\n20 PRINT I*2\n30 NEXT I"],
|
| 74 |
-
["10 SCREEN 1\n20 CIRCLE (160,100),50\n30 PAINT (160,100)"]
|
| 75 |
-
],
|
| 76 |
-
inputs=code_input
|
| 77 |
-
)
|
| 78 |
-
|
| 79 |
-
run_btn.click(
|
| 80 |
-
fn=process_basic_code,
|
| 81 |
-
inputs=code_input,
|
| 82 |
-
outputs=[text_out, image_out]
|
| 83 |
-
)
|
| 84 |
|
| 85 |
-
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
import subprocess
|
| 3 |
import tempfile
|
| 4 |
import os
|
|
|
|
| 41 |
except Exception as e:
|
| 42 |
return f"Erro: {str(e)}", None
|
| 43 |
|
| 44 |
+
# Configura莽茫o da interface Streamlit
|
| 45 |
+
st.title("PCBasic Interpreter Online")
|
| 46 |
+
|
| 47 |
+
code_input = st.text_area("C贸digo BASIC", placeholder="Digite seu c贸digo aqui...", height=300)
|
| 48 |
+
run_btn = st.button("Executar")
|
| 49 |
+
|
| 50 |
+
if run_btn:
|
| 51 |
+
text_output, img = run_pcbasic_code(code_input)
|
| 52 |
+
|
| 53 |
+
st.text_area("Sa铆da de Texto", text_output, height=200)
|
| 54 |
|
| 55 |
if img:
|
| 56 |
img_byte = io.BytesIO()
|
| 57 |
img.save(img_byte, format="PNG")
|
| 58 |
+
st.image(img_byte.getvalue(), caption="Sa铆da Gr谩fica")
|
|
|
|
| 59 |
|
| 60 |
+
# Exemplos de c贸digo BASIC
|
| 61 |
+
st.sidebar.title("Exemplos")
|
| 62 |
+
examples = [
|
| 63 |
+
"10 PRINT \"OL脕 MUNDO!\"",
|
| 64 |
+
"10 FOR I=1 TO 10\n20 PRINT I*2\n30 NEXT I",
|
| 65 |
+
"10 SCREEN 1\n20 CIRCLE (160,100),50\n30 PAINT (160,100)"
|
| 66 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
+
for example in examples:
|
| 69 |
+
if st.sidebar.button(example):
|
| 70 |
+
code_input = st.text_area("C贸digo BASIC", example, height=300)
|