show source code in lessions page

This commit is contained in:
Carl Zh.
2024-11-04 16:58:46 -06:00
parent 14e411f398
commit 90dc7e1448
6 changed files with 83 additions and 2 deletions

View File

@@ -38,3 +38,24 @@ def pythonx_lesson2():
ax.imshow(wordcloud, interpolation='bilinear')
plt.axis("off")
st.pyplot(fig)
source_code = """
import streamlit as st
from wordcloud import WordCloud
import matplotlib.pyplot as plt
text = st.text_area("Please input text to analyze")
if st.button("Analyze"):
# Create a WordCloud object
wordcloud = WordCloud(width=800, height=400, background_color='white').generate(text)
fig, ax = plt.subplots()
ax.imshow(wordcloud, interpolation='bilinear')
plt.axis("off")
st.pyplot(fig)
"""
st.divider()
st.subheader("**Source Code of the Sample App.**")
st.code(source_code, line_numbers=True)