I am close to launch my first app using streamlit but I am facing an issue.
I have a 2 part in my app. One landin/welcome page and the app itself with multiples pages.
The welcome page need to be in wide layout and the other in centered.
To put it simple, if the user is login, it’s contered, if not it’s wide.
Before I was using google authentification without cookies, for dev. And it was working ok because the user need to reload the page to login. So I can check if the user is auth, then I apply the page_config. But now I added extra_streamlit_components CookieManager. And because it need to run before I can use set_page_config, I get an error.
streamlit.errors.StreamlitAPIException: set_page_config() can only be called once per app page, and must be called as the first Streamlit command in your script.
I looked and couldn’t found a solution online. Look like nothing is possible. I could in theory use the multipages features of streamlit and add a set_page_config for each but then the user can access any page at any time, not what I want, and the layout is ugly and I can’t add stuff on top. (I know their is a hacky solution to that too but meh). Maybe it is possible to make a multipages but hide the pages? So I can manage in python the swap between pages.
Anybody have a solution ? It is a bit annoying as it is the only thing that I couln’t figure it out by searching or with hacky solution.
I will release the app soon, you will be able to see. But basically I have a chatbot that I want centered and dashboard that I want wide. Rn it is wide as default, so once login, you need to go to the option and manually change it. Not good enough as a user experience.
The issue with multiple column is that the chat_input appear on the top.
Also weird thing happed when resizing the app. And the app is build to be use on the side of another window, in a phone format.
So for I didn’t try anything else. As I said, without cookie everything worked fine but I need to use them.
I am not an expert in web dev as I’m more a data engineer/scientist. So I can’t implement cookies from nothing.
I asked here in last resort but I doubt there is any solution. I feel like I touch the limite of what streamlit is capable. I am missing a part in my tech sandwich to orchestrate all of that, like fastapi, django or flask. I will take a look as I will soon need to do a website in any case. So I can use the website as hub with authentification and payment to redirect to the app.
Because implementing google authentification was a nightmare, stripe too as they are suppose to be use with more conventional frameworks. And I can’t find a way to add more authentification API, which is a huge deal breaker on my side.
At this point I will also check the function itself in streamlit if I can create a small function like st.set_layout(“wide”). Derived from the set_page_config javascript function.
I know nothing is JS tho, so it’s gonna be fun.
Now my app is wide. But for the chatbot, the input is wide, which is nice because it is easier and the textbox are smaller and easier to read. Perfect.
Have you checked
1.streamlit_extras.switch_page_button import switch_page
2.st_pages these libraries . hope you find any insight out of this . st.switch_page - Streamlit Docs .
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.