We will be using a python web app framework called Streamlit.
Frameworks are great, as someone else has done most of the heavy coding to make it easier for you to carry out a task (in this case building a web app).
Module import
Direct import
libraries_1.py
import streamlit
or as an alias
libraries_2.py
import streamlit as st
Who is running what?
main.py
if__name__=="__main__": main()
Checks if the current file is being run as an imported library or directly
Streamlit methods
streamlit methods.py
import streamlit as st# Writes text to the browserst.write("Text to write to browser")# Creates a text input field# `step` is the increment for + - buttonsst.number_input("Label of input box", step=1)# Creates a select boxst.selectbox("Label for selectbox", ["first choice","second choice"])
magicEnabled = false
We have turned off a feature in Streamlit that shows all of your code in the browser using:
.streamlit/config.toml
[runner]magicEnabled = false
(See .streamlit/config.toml file if interested)
Stopping a running program
CTRL - C
or
CMD - C
Warning!
You are building an educational program. This is NOT to be used with real patients!
Time to install a framework
You now need to install the Streamlit framework. Don’t worry, it is very easy: