Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
# Streamlit Title
|
| 4 |
+
st.title("Streamlit App with Language Selector and HTML Rendering")
|
| 5 |
+
|
| 6 |
+
# Dropdown menu for selecting a programming language
|
| 7 |
+
language = st.selectbox("Pick a Programming Language:",
|
| 8 |
+
["C", "C++", "C#", "JavaScript", "Python", "HTML/CSS/JS"])
|
| 9 |
+
|
| 10 |
+
# Function to render markdown content with unsafe HTML based on the selected language
|
| 11 |
+
def render_language_content(selected_language):
|
| 12 |
+
if selected_language == "C":
|
| 13 |
+
st.markdown("<h3 style='color:blue;'>You selected C.</h3><p>Add your custom HTML here.</p>",
|
| 14 |
+
unsafe_allow_html=True)
|
| 15 |
+
elif selected_language == "C++":
|
| 16 |
+
st.markdown("<h3 style='color:green;'>You selected C++.</h3><p>Add your custom HTML here.</p>",
|
| 17 |
+
unsafe_allow_html=True)
|
| 18 |
+
elif selected_language == "C#":
|
| 19 |
+
st.markdown("<h3 style='color:orange;'>You selected C#.</h3><p>Add your custom HTML here.</p>",
|
| 20 |
+
unsafe_allow_html=True)
|
| 21 |
+
elif selected_language == "JavaScript":
|
| 22 |
+
st.markdown("<h3 style='color:red;'>You selected JavaScript.</h3><p>Add your custom HTML here.</p>",
|
| 23 |
+
unsafe_allow_html=True)
|
| 24 |
+
elif selected_language == "Python":
|
| 25 |
+
st.markdown("""<iframe width="1000" height="600" src="https://codehs.com/sandbox/id/python-3-kr6mEw/embed/?display_mode=default" frameborder="0" allowfullscreen class="video-iframe"></iframe>""",
|
| 26 |
+
unsafe_allow_html=True)
|
| 27 |
+
elif selected_language == "HTML/CSS/JS":
|
| 28 |
+
st.markdown("<h3 style='color:pink;'>You selected HTML/CSS/JS.</h3><p>Add your custom HTML here.</p>",
|
| 29 |
+
unsafe_allow_html=True)
|
| 30 |
+
|
| 31 |
+
# Call the function to render the selected content
|
| 32 |
+
render_language_content(language)
|