Options to to display programming code and results

Hello,

New to this forum and would like to get some suggestions on how to expand my current project.

My goal is to use the sidebar to select, display and execute different pieces of code (Python and SQL) and the results displayed in the same area. I want to showcase the work I’ve done with others.

Here is my code so far:

# Import statements
import streamlit as st
import numpy as np
import pandas as pd

st.set_page_config(
    page_title='Marks Code Examples',
    layout='wide',
    initial_sidebar_state='expanded')

st.sidebar.title('My code examples') #sidebar is the widget, title is the element
st.sidebar.markdown('by Mark Moralls')

st.sidebar.date_input('Date')
st.sidebar.time_input('Time')

# title for this code
st.title('Covid 19 Data')

# specify column content; success gives the column a green color


#[decorator]; data will be downloaded only once and cached for future use
st.write('Python Code')

with st.echo():

    @st.cache 

    def get_data():
        url = 'https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv'
        return pd.read_csv(url)

st.write('Code Results')

#[decorator]; data will be downloaded only once and cached for future use

def get_data():
    url = 'https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv'
    return pd.read_csv(url)

df = get_data()
st.dataframe(df.head())

Much obliged for any help!