# Python

Source : https://webgune.cloud/es-es/docs/web-python · Mis à jour le 2026-10-27

# Python

La presencia de `requirements.txt`, `pyproject.toml` o `Pipfile` activa la detección de Python. Se usa Python 3.12 por defecto.

## FastAPI

```python
# main.py
from fastapi import FastAPI

app = FastAPI()

@app.get("/")
def root():
    return {"message": "Hello Webgune"}
```

```text
# requirements.txt
fastapi
uvicorn[standard]
```

Comando de inicio (a definir si el builder automático no lo detecta):

```bash
uvicorn main:app --host 0.0.0.0 --port $PORT
```

## Django

```bash
DATABASE_URL=postgresql://user:pass@host:5432/db
DJANGO_SECRET_KEY=cambiame
DJANGO_ALLOWED_HOSTS=tu-dominio.webgune.dev
```

```bash
python manage.py migrate
gunicorn miproyecto.wsgi:application --bind 0.0.0.0:$PORT
```

## Flask

```bash
gunicorn app:app --bind 0.0.0.0:$PORT --workers 2
```

> Sea cual sea el framework, no uses el servidor de desarrollo (`flask run`, `manage.py runserver`) en producción. Usa Gunicorn o Uvicorn, más robustos bajo carga.
