Sistemas Operativos - Servicios y procesos en Linux
En sistemas Linux, los servicios son procesos que permanecen en ejecución para atender solicitudes. En esta práctica se desplegará un servicio web real utilizando FastAPI.
ssh usuario@IP_SERVIDOR
Requiere Python 3:
python3 --version
sudo apt update
sudo apt install python3-pip -y
pip3 install fastapi uvicorn
Crear archivo:
nano app.py
Pegar el siguiente código:
from fastapi import FastAPI
app = FastAPI()
@app.get("/")
def home():
return {"mensaje": "Servidor funcionando correctamente"}
uvicorn app:app --host 0.0.0.0 --port 8000
Acceder desde navegador:
http://IP_SERVIDOR:8000
uvicorn app:app --host 0.0.0.0 --port 8000 &
Ver proceso:
ps aux | grep uvicorn
ss -tuln | grep 8000