Files

Directory Structure

main.py

Is that it? Yes.

We will use main.py to start the Streamlit app, passing in the python file name we want to use for the home page. In this case, home.py. Speaking of home.py, let’s look at it next.

home.py

Hmmm… this is not looking too complicated. And you would be correct.

Many folks will name the home page file, app.py. I deviated a little bit from convention here, in order to help keep track of what is going. on.

Now let’s go line by line


home.py – library import

We import some standard libraries that are used in the python world, pandas, yaml, os, and of course streamlit. The appendix will contain details on how to install the packages.

Next we will import some local files that we will create below.

PandasSQLHandler

DataHandler

sql_column_config


main.py – main()

We aliased the streamlit package as st, which is pretty common alias for the package.

In the main function, we will call three streamlit methods.

By default streamlit will limit the width of the content on the webpage. For our tutorial, I will set the layout to wide, to allow for using the complete width of the browser window.

Next we will add a title for the page. By default it is size of H1 html tag.

The last bit is to add some text, supporting markdown. You could also use some the st.text method to accomplish the same thing.

If you were to run the app you would see the following, without the menu on the sidebar, we will get to that part in a moment.