Skip to main content
The application can be run using automated scripts or manually. The automated method is recommended for quick setup.

Prerequisites

Before running the application, ensure you have:
  • Python 3.10 or 3.11
  • pip (Python package manager)
  • Virtual environment activated
  • All dependencies installed from requirements.txt
The application requires two servers to run:
  • ICE Server on port 10000 (backend communication)
  • Flask Web Server on port 5000 (web interface)
The project includes automated run scripts that handle starting both servers for you.
1

Make script executable (first time only)

chmod +x run.sh
2

Run the script

./run.sh
3

Expected output

🚀 Iniciando Conversor de Unidades...

[1/3] Levantando ICE Server en puerto 10000
ICE PID: 12345
[2/3] Levantando Flask Server en puerto 5000
Flask PID: 12346
[3/3] ¿Quieres levantar ngrok para acceso remoto? (s/n)
4

Choose ngrok option

Type n to run locally without ngrok:
 Servidores activos:
   - ICE Server: http://localhost:10000
   - Web App: http://localhost:5000
Presiona Ctrl+C para detener
The script automatically handles process cleanup when you press Ctrl+C

How the Automated Scripts Work

The scripts perform the following operations:
  1. Validate that you’re running from the project root directory
  2. Start the ICE server in the background (backend/server.py)
  3. Wait 3 seconds for ICE server initialization
  4. Start the Flask web server in the background (backend/web_server.py)
  5. Wait 2 seconds for Flask server initialization
  6. Prompt for optional ngrok tunnel setup
  7. Handle graceful shutdown with Ctrl+C
# Terminal 1: ICE Server
echo -e "${GREEN}[1/3] Levantando ICE Server en puerto 10000${NC}"
cd backend
python3 server.py &
ICE_PID=$!

# Esperar a que ICE esté listo
sleep 3

# Terminal 2: Flask Server
echo -e "${GREEN}[2/3] Levantando Flask Server en puerto 5000${NC}"
python3 web_server.py &
FLASK_PID=$!

Manual Setup

If you prefer more control or need to debug individual components, you can start each server manually.
1

Open two terminal windows

You’ll need separate terminals for the ICE server and Flask server.
2

Activate virtual environment in both terminals

cd /path/to/Conversor_Unidades_Remoto-1
source .venv/bin/activate
3

Start ICE server (Terminal 1)

cd backend
python3 server.py
You should see output confirming the server is listening on port 10000.
4

Start Flask web server (Terminal 2)

cd backend
python3 web_server.py
Expected output:
 Iniciando servidor Flask...
 Conectado al servidor ICE en puerto 10000
 Servidor Flask escuchando en http://localhost:5000
  Para exponerlo con ngrok ejecuta: ngrok http 5000
5

Access the application

Open your browser and navigate to:
http://localhost:5000
Make sure to start the ICE server before the Flask server. The Flask server needs to connect to the ICE server during startup.

Verifying the Setup

Once both servers are running, you can verify the setup:

Check Server Status

Visit the status endpoint:
curl http://localhost:5000/api/status
Expected response:
{
  "connected": true,
  "servidor": "localhost:10000"
}

Check Available Units

Test the API by requesting available temperature units:
curl http://localhost:5000/api/unidades/temperatura
Expected response:
{
  "unidades": "celsius, fahrenheit, kelvin"
}

Test a Conversion

Perform a sample conversion:
curl -X POST http://localhost:5000/api/convert \
  -H "Content-Type: application/json" \
  -d '{
    "categoria": "temperatura",
    "valor": 32,
    "desde": "fahrenheit",
    "hasta": "celsius"
  }'
Expected response:
{
  "resultado": 0.0
}

Troubleshooting

ICE Server Connection Failed

If you see “No se pudo conectar al servidor ICE”:
  1. Verify the ICE server is running
  2. Check if port 10000 is available
lsof -i :10000

Port Already in Use

If port 5000 is already occupied:
# Find process using port 5000
lsof -i :5000

# Kill the process (replace PID)
kill -9 <PID>
Alternatively, use environment variables to run Flask on a different port.

Virtual Environment Not Activated

If you get import errors, ensure your virtual environment is activated:
# You should see (.venv) in your prompt
(.venv) user@machine:~/project$

Stopping the Application

Automated Scripts

Press Ctrl+C in the terminal running the script. The cleanup function will automatically terminate both servers.

Manual Setup

Press Ctrl+C in each terminal window to stop the respective servers.

Next Steps

Environment Variables

Configure host, port, and debug settings

ngrok Tunnel

Expose your local server to the internet

Build docs developers (and LLMs) love