streamlit / streamlit

Streamlit — A faster way to build and share data apps.
https://streamlit.io
Apache License 2.0
34.94k stars 3.03k forks source link

For beta_set_page_config, page_title still includes "Streamlit" #1856

Closed randyzwitch closed 3 years ago

randyzwitch commented 4 years ago

When running st.beta_set_page_config(page_title="streamlit-embedcode documentation",), the Streamlit app appends an extra · Streamlit value to the string:

<title>streamlit-embedcode documentation · Streamlit</title>

In letting the user set the value, we should not display anything other than what the user wrote.

mechatronics-studio commented 4 years ago

I noticed this too. Since it was reverted from bug to product review needed, does that mean this is an intended functionality?

Daniyal56 commented 3 years ago

When running on local host it's showing "streamlit-embedcode documentation · Streamlit", but i don't want this append value · Streamlit, how can i do this, urgent response is needed please.

anlinguist commented 3 years ago

As a temporary workaround, you can modify the streamlit frontend main file to remove "· Streamlit" from the title.

  1. Go to site-packages/streamlit/static/static/js/ and find the 'main...chunk.js' file and open it.
  2. Search for document.title="".concat(t," \xb7 Streamlit") and replace it with document.title="".concat(t,"")
  3. Restart streamlit app and "· Streamlit" should be gone from the title
aniruddhachoudhury commented 3 years ago

I am chaging the same inside a docker container after that i am deploying. So it crashing. What might be the possibile solution for docker deployment changes?

anlinguist commented 3 years ago

how are you changing it in the docker container?

I imagine you're installing streamlit as a requirement? After the RUN pip install -r requirements.txt command, you need to have another command, something like RUN sed -i 's/document.title="".concat(t," \xb7 Streamlit")/document.title="".concat(t,"")/g' site-packages/streamlit/static/static/js/main...chunk.js. You'll need to change the main....chunk.js to whatever it actually is on your version (I think it changes between versions). I was actually doing this before but recently switched to Dash, so I can't recall exactly how I was doing it.

aniruddhachoudhury commented 3 years ago

Yes i am installing the streamlit as in requirements.txt. Once i have build that docker image. I am entering inside docker as docker run -it $IMAGE_NAME /bin/bash. Inside the docker i am going to that site packages path and with VIM editor i am changing that. I am hosting the docker image in Cloud as a deployment. Can you share me the docker image code if it is working there.

anlinguist commented 3 years ago

add these docker commands in your dockerfile after you install requirements.txt: WORKDIR / RUN sed -i 's/ \\xb7 Streamlit//g' /usr/local/lib/python3.8/site-packages/streamlit/static/static/js/main.68bdddd4.chunk.js

So long as that's the name of the main...chunk.js file, it should work - I just tested it and it worked fine for me. You may need to change the python version number depending on which version you're using.

aniruddhachoudhury commented 3 years ago

Let me test that. Thanks for quick reply.

aniruddhachoudhury commented 3 years ago

Thanks its working solution. I think we can close this issue.

anlinguist commented 3 years ago

I think the issue still stands, the page title should not include '· Streamlit' if set_page_config has been set.

aniruddhachoudhury commented 3 years ago

Ya correct once you refresh the page the stremlit title and the default favicon.png image still comes.

anlinguist commented 3 years ago

That shouldn't be happening 🤔 you completely removed the code to add the '· Streamlit' with that RUN sed command, so that's strange that it would come back. Did you set_page_config in your app.py?

randyzwitch commented 3 years ago

Could you take this to the Streamlit forum? This is triggering notifications to everyone following this issue, whereas yours is a specific, tangentially related question.

https://discuss.streamlit.io

Thanks!

aniruddhachoudhury commented 3 years ago

That shouldn't be happening 🤔 you completely removed the code to add the '· Streamlit' with that RUN sed command, so that's strange that it would come back. Did you set_page_config in your app.py?

Yes i have set page config at the starting of my code with custom title and image.

aniruddhachoudhury commented 3 years ago

Could you take this to the Streamlit forum? This is triggering notifications to everyone following this issue, whereas yours is a specific, tangentially related question.

https://discuss.streamlit.io

Thanks!

Sure will take that.

aniruddhachoudhury commented 3 years ago

That shouldn't be happening 🤔 you completely removed the code to add the '· Streamlit' with that RUN sed command, so that's strange that it would come back. Did you set_page_config in your app.py?

Yes i have set page config at the starting of my code with custom title and image.

For first time launch or whenever you will refresh it shows the streamlit name. Once the page is refreshed fully it comes back to our custom title. So intially it shows for 2 secs at starti g point of loading a page thats the problem

mzeidhassan commented 3 years ago

Any update on this one? I thought this would be an easy fix from Streamlit team's side.

officiallymarky commented 3 years ago

Would be nice to have this fixed, also if you use a custom title it flashes "Streamlit" first before displaying the custom title favicon, would be nice if it didn't do that as well.

KevinAQM commented 3 years ago

@anlinguist, how can I add my path correctly to dockerfile?

C:\Users\KevinAQM\anaconda3\Lib\site-packages\streamlit\static\static\js

I'm getting an "error" when I'm deploying my app to the GCP APP Engine. Error I get occurs on dockerfile, exactly on that codeline: RUN sed -i ........

Thanks to all.

okld commented 3 years ago

Here's another hacky solution which doesn't require to change streamlit files. You can use the following function directly in your apps:

def set_page_title(title):
    st.sidebar.markdown(unsafe_allow_html=True, body=f"""
        <iframe height=0 srcdoc="<script>
            const title = window.parent.document.querySelector('title') \

            const oldObserver = window.parent.titleObserver
            if (oldObserver) {{
                oldObserver.disconnect()
            }} \

            const newObserver = new MutationObserver(function(mutations) {{
                const target = mutations[0].target
                if (target.text !== '{title}') {{
                    target.text = '{title}'
                }}
            }}) \

            newObserver.observe(title, {{ childList: true }})
            window.parent.titleObserver = newObserver \

            title.text = '{title}'
        </script>" />
    """)

This will however add a small padding where you'll call the function.

Caution: for security reasons, do not let the app user change that title with a text_input or anything else.

set_page_title("My title")  # OK
set_page_title(st.text_input("Edit my title"))  # Security risks
feliperoque commented 3 years ago

any news on this bug?

tconkling commented 3 years ago

This was fixed in 0.84, which went out last week: https://docs.streamlit.io/en/stable/changelog.html

KeeonTabrizi commented 2 years ago

@tconkling I know I'm bumping an old thread - but did those changes actually do anything given later in src/App.tsx we see this:

https://github.com/streamlit/streamlit/blob/9238905c88d1769e47d580ccceb1347242527ad3/frontend/src/App.tsx#L723

Rchatru commented 1 year ago

I still have the same problem. I'm on version 1.16 and it seems that the changes have had no effect.

st.set_page_config(
    page_title="Test - Home",
    page_icon="👀",
    layout="centered",
    initial_sidebar_state="auto",
    menu_items={
        'Get Help': 'https://github.com/-',
        'Report a bug': "https://github.com/-",
        'About': "WebApp."
    }
)

Using the above configuration shows: "Test -Home · Streamlit". I can't get the icon to appear either. It is empty. This is strange as it worked months ago and I haven't changed anything in this part of the code.

Edit: The icon issue is related to #5942