简体   繁体   English

Heroku 完全忽略config.toml文件

[英]Heroku completely ignores config.toml file

I just made my website using streamlit and have uploaded it to heroku. I have a config.toml file in the.streamlit folder, which changes the text colour and background colour of the website.我刚刚用streamlit制作了我的网站并上传到heroku。我在.streamlit文件夹中有一个config.toml文件,它改变了网站的文本颜色和背景颜色。

On running it by using the streamlit run command, it works perfectly fine.使用streamlit run命令运行它时,它运行得非常好。 But using heroku and going to the provided website, the text colour there seems to be black and the background white, which are not the correct colours.但是使用 heroku 并转到提供的网站,那里的文字颜色似乎是黑色,背景是白色,这不是正确的颜色。

Here is my setup.sh file:这是我的setup.sh文件:

mkdir -p ~/.streamlit/

echo "\
[general]\n\
email = \"myname@domain.com\"\n\
" > ~/.streamlit/credentials.toml

echo "\
[server]\n\
headless = true\n\
enableCORS=false\n\
port = $PORT\n\
" > ~/.streamlit/config.toml

Here is my config.toml file:这是我的config.toml文件:

[theme]
primaryColor = '#eb4034'
backgroundColor = '#021d24'
secondaryBackgroundColor = '#B9F1C0'
textColor = '#FFFFFF'
font = "sans serif"

Here is my config.toml file这是我的config.toml文件

I'm not sure where that content comes from, but it won't be in your config.toml on Heroku because you create or overwrite that file in your setup.sh .我不确定该内容来自何处,但它不会在 Heroku 上的config.toml中,因为您在setup.sh中创建或覆盖了该文件。

echo ing stuff and redirecting it into a file using > overwrites what's already there. echo将内容重定向到一个文件中,使用>覆盖已经存在的内容。

If that file already exists (unlikely on Heroku, but I'm not familiar with Streamlit so maybe it gets generated somehow), change > to >> so you append to the existing file instead:如果该文件已经存在(不太可能在 Heroku 上,但我不熟悉 Streamlit,所以它可能以某种方式生成),请将>更改为>> ,以便将append 改为现有文件:

echo "\
[server]\n\
headless = true\n\
enableCORS=false\n\
port = $PORT\n\
" >> ~/.streamlit/config.toml  # <-- Here

Or, add the [theme] section to your setup.sh (note the change to single quotes around #FFFFFF ):或者,将[theme]部分添加到您的setup.sh (注意#FFFFFF周围单引号的变化):

echo "\
[server]\n\
headless = true\n\
enableCORS=false\n\
port = $PORT\n\
\n\
[theme]\n\
primaryColor = '#eb4034'\n\
backgroundColor = '#021d24'\n\
secondaryBackgroundColor = '#B9F1C0'\n\
textColor = '#FFFFFF'\n\
font = 'sans serif'\n\
" > ~/.streamlit/config.toml

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM