Skip to content

Instantly share code, notes, and snippets.

@urigoren
Created November 7, 2020 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save urigoren/fa84538c80cf693ef79c2c880885bc3e to your computer and use it in GitHub Desktop.
Save urigoren/fa84538c80cf693ef79c2c880885bc3e to your computer and use it in GitHub Desktop.
import sys, os
import streamlit as st
def file2page_name(fname):
return fname.replace('.py', '').split("_", 1)[1].title()
sys.path.append("..")
page_files = dict()
for fname in os.listdir('.'):
if fname.startswith("page_") and fname.endswith(".py"):
page_files[file2page_name(fname)] = fname
page = st.sidebar.radio("Pages ", list(page_files.keys()), 0)
st.write("# " + page)
with open(page_files[page], 'r') as f:
exec(f.read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment