Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,54 +1,8 @@
|
|
| 1 |
import streamlit as st
|
|
|
|
| 2 |
import sys
|
| 3 |
import io
|
| 4 |
|
| 5 |
-
# CSS for background image and custom styling
|
| 6 |
-
tabs_css = """
|
| 7 |
-
<style>
|
| 8 |
-
/* Full-screen background image */
|
| 9 |
-
.stApp {
|
| 10 |
-
background: url('https://huggingface.co/spaces/MLDeveloper/code_compiler/resolve/main/images/blank.png') no-repeat center center fixed;
|
| 11 |
-
background-size: cover;
|
| 12 |
-
}
|
| 13 |
-
/* Remove the white background box in header */
|
| 14 |
-
.stHeader, .stSubheader {
|
| 15 |
-
background-color: transparent !important;
|
| 16 |
-
}
|
| 17 |
-
/* Remove any background box around the text */
|
| 18 |
-
.stMarkdown, .stTitle, .stText, .stList, .stSubheader {
|
| 19 |
-
background-color: transparent;
|
| 20 |
-
color: black !important;
|
| 21 |
-
font-weight: bold;
|
| 22 |
-
}
|
| 23 |
-
/* Custom styling for tabs */
|
| 24 |
-
.stTabs [data-baseweb="tab-list"] {
|
| 25 |
-
background-color: white;
|
| 26 |
-
border-radius: 20px;
|
| 27 |
-
padding: 5px;
|
| 28 |
-
box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.1);
|
| 29 |
-
}
|
| 30 |
-
.stTabs [data-baseweb="tab"] {
|
| 31 |
-
color: #B71C1C;
|
| 32 |
-
font-weight: bold;
|
| 33 |
-
border-radius: 20px;
|
| 34 |
-
padding: 10px 20px;
|
| 35 |
-
}
|
| 36 |
-
.stTabs [aria-selected="true"] {
|
| 37 |
-
background-color: #FAE5D3 !important;
|
| 38 |
-
color: #B71C1C !important;
|
| 39 |
-
font-weight: bold;
|
| 40 |
-
}
|
| 41 |
-
/* Add some padding and styling to text boxes */
|
| 42 |
-
.stTextInput, .stTextArea {
|
| 43 |
-
font-size: 16px;
|
| 44 |
-
padding: 10px;
|
| 45 |
-
border-radius: 8px;
|
| 46 |
-
border: 1px solid #ccc;
|
| 47 |
-
}
|
| 48 |
-
</style>
|
| 49 |
-
"""
|
| 50 |
-
st.markdown(tabs_css, unsafe_allow_html=True)
|
| 51 |
-
|
| 52 |
def execute_code(code, user_input=""):
|
| 53 |
"""Execute the given code with simulated input and return the output."""
|
| 54 |
old_stdout = sys.stdout # Backup original stdout
|
|
@@ -82,20 +36,17 @@ st.title("💻 Python Compiler 🐍")
|
|
| 82 |
st.write("Write your Python code and get the correct output!")
|
| 83 |
|
| 84 |
code_input = st.text_area("Enter your Python code:", height=200)
|
| 85 |
-
user_input = st.text_area("Enter input values (one per line):", height=100)
|
| 86 |
|
| 87 |
if st.button("Run Code"):
|
| 88 |
if code_input.strip():
|
| 89 |
with st.spinner("Executing..."):
|
| 90 |
-
output = execute_code(code_input, user_input)
|
| 91 |
st.subheader("Output:")
|
| 92 |
st.code(output, language="plaintext")
|
| 93 |
else:
|
| 94 |
st.warning("⚠️ Please enter some Python code before running.")
|
| 95 |
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
|
| 100 |
# V1 without gemini api
|
| 101 |
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import streamlit as st
|
| 3 |
import sys
|
| 4 |
import io
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
def execute_code(code, user_input=""):
|
| 7 |
"""Execute the given code with simulated input and return the output."""
|
| 8 |
old_stdout = sys.stdout # Backup original stdout
|
|
|
|
| 36 |
st.write("Write your Python code and get the correct output!")
|
| 37 |
|
| 38 |
code_input = st.text_area("Enter your Python code:", height=200)
|
| 39 |
+
user_input = st.text_area("Enter input values (one per line):", height=100) # Added input field
|
| 40 |
|
| 41 |
if st.button("Run Code"):
|
| 42 |
if code_input.strip():
|
| 43 |
with st.spinner("Executing..."):
|
| 44 |
+
output = execute_code(code_input, user_input) # Execute user code with mock input
|
| 45 |
st.subheader("Output:")
|
| 46 |
st.code(output, language="plaintext")
|
| 47 |
else:
|
| 48 |
st.warning("⚠️ Please enter some Python code before running.")
|
| 49 |
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
# V1 without gemini api
|
| 52 |
|