1. Display Source Code to Provide a Context
When you’re displaying data to your peers who are interested in viewing your code, it’s useful to show your code in the web app. To do this, you can use the
It’s often useful to show the code that is directly responsible for the widget or its related data. The trick is to use the
echo function, as shown below.
fruits = ['apple', 'banana']
http_response = (404, 'Page Not Found')
st.radio("Choose Fruit", fruits)
st.text_input("HTTP Responses", http_response)
The following figure shows you what you’ll see on the screen. In essence, everything in the with statement will be included in a code block.