![](/img/trans.png)
[英]Streamlit config.toml file not changing the theme of the web app
[英]Heroku completely ignores config.toml file
我刚刚用streamlit制作了我的网站并上传到heroku。我在.streamlit文件夹中有一个config.toml文件,它改变了网站的文本颜色和背景颜色。
使用streamlit run
命令运行它时,它运行得非常好。 但是使用 heroku 并转到提供的网站,那里的文字颜色似乎是黑色,背景是白色,这不是正确的颜色。
这是我的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
这是我的config.toml
文件:
[theme]
primaryColor = '#eb4034'
backgroundColor = '#021d24'
secondaryBackgroundColor = '#B9F1C0'
textColor = '#FFFFFF'
font = "sans serif"
这是我的
config.toml
文件
我不确定该内容来自何处,但它不会在 Heroku 上的config.toml
中,因为您在setup.sh
中创建或覆盖了该文件。
echo
将内容重定向到一个文件中,使用>
覆盖已经存在的内容。
如果该文件已经存在(不太可能在 Heroku 上,但我不熟悉 Streamlit,所以它可能以某种方式生成),请将>
更改为>>
,以便将append 改为现有文件:
echo "\
[server]\n\
headless = true\n\
enableCORS=false\n\
port = $PORT\n\
" >> ~/.streamlit/config.toml # <-- Here
或者,将[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.