Projeto Streamlit com CSS Injection · HTML Render · Conversão IMG → Base64
Deploy automático via GitHub + Streamlit Community Cloud
imagem-em-movimento/
│
├── app.py ← Estrutura 1 · Script principal Streamlit
├── img_to_base64.py ← Estrutura 2 · Conversor IMG → Base64
├── logo.png ← Imagem do logotipo (Venom)
├── requirements.txt ← Estrutura 3 · Dependências do projeto
└── README.md ← Este ficheiro
Script Streamlit que combina duas técnicas para renderizar a imagem animada:
| Técnica | Descrição |
|---|---|
| CSS Injection | Estilos injetados via st.markdown(..., unsafe_allow_html=True) |
| HTML Render | Bloco HTML completo renderizado dentro do Streamlit |
| Base64 Embed | Imagem embutida no HTML como Data URI — sem ficheiros externos |
# Injeção de CSS global
st.markdown(CSS, unsafe_allow_html=True)
# Renderização do HTML com imagem embutida
st.markdown(HTML, unsafe_allow_html=True)Animações CSS incluídas:
venom-float— flutuação suave da imagemvenom-glow— pulso de brilho neon azul ↔ roxospin— anéis orbitais giratórios (sentidos opostos)flicker— efeito de cintilação no títuloambient-pulse— glow ambiente radial de fundodrip-pulse— barra de energia pulsante
Módulo de conversão de imagem para string Base64, importado pelo app.py.
Pipeline de conversão:
logo.png
│
▼ file.read_bytes()
[bytes binários] → b'\x89PNG\r\n...'
│
▼ base64.b64encode()
[bytes Base64] → b'iVBORw0KGgo...'
│
▼ .decode("utf-8")
[string Base64] → 'iVBORw0KGgo...'
│
▼ embutida no HTML
src="data:image/png;base64,iVBORw0KGgo..."
Funções disponíveis:
from img_to_base64 import img_to_base64, get_mime_type, img_to_data_uri
# Retorna string Base64 pura
b64 = img_to_base64("logo.png")
# Retorna o MIME type correto
mime = get_mime_type("logo.png") # → "image/png"
# Retorna o Data URI completo
uri = img_to_data_uri("logo.png") # → "data:image/png;base64,..."Formatos suportados: .png · .jpg · .jpeg · .webp · .gif · .svg
Testar via terminal:
python img_to_base64.py logo.pngstreamlit>=1.35.0
base64epathlibsão bibliotecas nativas do Python e não precisam ser declaradas.
1. Clonar o repositório
git clone https://github.com/SEU_USER/SEU_REPO.git
cd SEU_REPO2. Instalar dependências
pip install -r requirements.txt3. Lançar a aplicação
streamlit run app.pyAcede em: http://localhost:8501
1. Push para o GitHub
git add app.py logo.png requirements.txt img_to_base64.py README.md
git commit -m "feat: imagem em movimento — estrutura completa"
git push -u origin main2. Conectar ao Streamlit Cloud
| Campo | Valor |
|---|---|
| Repository | SEU_USER/SEU_REPO |
| Branch | main |
| Main file path | app.py |
Acede a share.streamlit.io → New app → preenche os campos → Deploy!
3. Atualizações automáticas
A cada git push, o Streamlit Cloud faz o redeploy automaticamente — sem nenhuma ação manual.
git add .
git commit -m "update: nova versão"
git push| Token | Cor | Uso |
|---|---|---|
--accent |
#00b4ff |
Azul neon — orbits, glow, pills |
--accent2 |
#bf00ff |
Roxo — gradiente, segunda orbit |
--accent3 |
#6e00ff |
Roxo profundo — ambient glow |
--bg |
#000005 |
Fundo absoluto |
--text |
#c8d8ff |
Texto principal |
MIT © 2025 — Livre para uso e modificação.