Data collision with multiple app pages

Hereโ€™s the simplest top level for a multi-page app (I use all the time). You will of course need to implement app1.py and app2.py yourself. If app1.main() or app2.main() take arguments, then add them as comma separated elements in the pages spec, e.g. [app1.main, 'arg 1', 'arg 2'].

import streamlit as st
import app1, app2

def main():
    pages = {
        'App 1': [app1.main],    # APP 1
        'App 2': [app2.main],    # APP 2
    }

    choice = st.sidebar.radio('What do you want to do?', tuple(pages.keys()))
    pages[choice][0](*pages[choice][1:])

if __name__ == '__main__':
    main()

Hope that helps.

1 Like