mkdir "name"cd "name"python3 --versionpython3 -m venv .venvsource .venv/bin/activatedeactivatepip install streamlitpip install --upgrade pippip install watchdog- Presiona
⌘ + P - Escribe
>Python: Select Interpreter - Selecciona el intérprete recomendado:
.venv
touch app.pystreamlit run app.pyAlternativa si el comando anterior no funciona:
python -m streamlit run app.pynombre-proyecto/
├── app.py # Punto de entrada principal
├── requirements.txt # Dependencias del proyecto
├── railway.json # Configuración de despliegue
├── .venv/ # Entorno virtual (no subir a GitHub)
├── .gitignore # Archivos ignorados por Git
└── pages/
├── menu_pages.py # Configuración de navegación
├── home.py # Página de bienvenida
├── page1.py # Página 1
├── page2.py # Página 2
└── page3.py # Página 3
import streamlit as st
from pages.menu_pages import build_navigation
st.set_page_config(
page_title="Nombre App",
page_icon=":material/home:"
)
page = build_navigation()
page.run()import streamlit as st
def build_navigation():
home = st.Page(title="Inicio", page="pages/home.py",
icon=":material/home:", default=True)
page1 = st.Page(title="Página 1", page="pages/page1.py",
icon=":material/check_circle:")
return st.navigation(
{"": [home], "Sección 1": [page1]},
position="top"
)cat > .gitignore << 'EOF'
.venv/
__pycache__/
*.pyc
.DS_Store
.env
EOFReglas clave:
set_page_configsolo enapp.py, antes de todost.navigationsolo dentro de una función, nunca en el cuerpo del módulo- Las subpáginas no llaman
set_page_confignist.navigation
git --versionsource .venv/bin/activate
pip freeze > requirements.txt
cat requirements.txtcat > railway.json << 'EOF'
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS"
},
"deploy": {
"startCommand": "streamlit run app.py --server.address 0.0.0.0 --server.port $PORT --server.fileWatcherType none --browser.gatherUsageStats false"
}
}
EOFgit init
git add .
git commit -m "initial commit"En GitHub crea un repo vacío (sin README), luego:
git remote add origin https://github.com/TU_USUARIO/TU_REPO.git
git branch -M main
git push -u origin main# Instalar Railway CLI
npm install -g @railway/cli
# Login
railway login
# Crear proyecto nuevo
railway init
# Vincular al repo (si ya lo creaste desde GitHub)
railway link
# Desplegar
railway uprailway domainGenera una URL tipo
tu-proyecto.up.railway.app
railway logsCada vez que hagas cambios:
git add .
git commit -m "descripcion del cambio"
git pushRailway redespliega automáticamente al detectar el push en GitHub.