code compiler
To upload files, please first save the app
import streamlit as st
st.title("📝 Code Compiler")
# Text area for code input
code = st.text_area("Enter your code here:", height=300)
# Language selection
language = st.selectbox(
"Select programming language:",
["python", "javascript", "java", "cpp", "csharp", "ruby", "golang", "rust", "sql"]
)
# Display code with syntax highlighting
if code:
st.subheader("Code Preview with Syntax Highlighting:")
st.code(code, language=language, line_numbers=True)
# Add a download button for the code
st.download_button(
label="Download Code",
data=code,
file_name=f"code.{language}",
mime="text/plain"
)
# Add some helpful instructions
with st.expander("How to use"):
st.markdown("""
1. Enter your code in the text area above
2. Select the programming language from the dropdown
3. Your code will be displayed with syntax highlighting
4. Use the download button to save your code to a file
Note: This is a code viewer/formatter. It does not execute the code.
""")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?