Deployment
Development and production have different running methods. Production environments use WSGI/ASGI servers and reverse proxies.
Technology Choices:
- WSGI: Gunicorn + gevent/Meinheld, or Waitress (Windows)
- ASGI: Uvicorn + asgiref (Flask 3 provides experimental async view support)
- Frontend with Nginx/Apache for reverse proxy, TLS, static resources
Gunicorn Example:
bash
pip install gunicorn gevent
export FLASK_APP=app:create_app
gunicorn -w 4 -k gevent -b 0.0.0.0:8000 "app:create_app()"Containerization:
dockerfile
FROM python:3.11-slim
WORKDIR /app
COPY . .
RUN pip install -r requirements.txt
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:8000", "app:create_app()"]Configuration:
- Inject sensitive information through environment variables
- Enable health checks and readiness probes
- Use process management/daemons (systemd/supervisor)