# Python

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

# Python

La présence de `requirements.txt`, `pyproject.toml` ou `Pipfile` déclenche la détection Python. Python 3.12 est utilisé par défaut.

## FastAPI

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

app = FastAPI()

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

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

Commande de démarrage (à définir si le builder auto ne la détecte pas) :

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

## Django

```bash
DATABASE_URL=postgresql://user:pass@host:5432/db
DJANGO_SECRET_KEY=change-moi
DJANGO_ALLOWED_HOSTS=votre-domaine.webgune.dev
```

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

## Flask

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

> Quel que soit le framework, n'utilisez pas le serveur de développement (`flask run`, `manage.py runserver`) en production. Préférez Gunicorn ou Uvicorn, plus robustes sous charge.
