> For the complete documentation index, see [llms.txt](https://haleyryu.gitbook.io/engineer/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://haleyryu.gitbook.io/engineer/python/wsgi/web-server-wsgi-middleware-application.md).

# Web Server / WSGI / Middleware / Application 구조

Web Server / WSGI / Middleware / Application 의 구조와 각 요소별 역할

## 전체 구조&#x20;

## 전체 Flow

1. Web Server 로 HTTP Request 가 들어옵니다.
2. Server-side 작업이 필요한 경우,  WSGI Middleware 를 통해 Application 으로 Request 를 전달합니다.
3. Application 에서 로직을 통해 Request 를 처리한 후, WSGI Middleware 를 통해 Response 를 돌려줍니다.

**🔍 각 컴포넌트 상세**&#x20;

### WAS&#x20;

* Nginx + Gunicorn 위에 Flask 로 만든 REST API Application 을 올리면 WAS 가 구성된 것입니다.

### WSGI

* **Web Server Gateway Interface**
* Web Server 가 받은 호출을 Python Application 에 전달하고 응답받는 등 서로 통신하기 위해 필요한 호출 Convention 입니다.

### WSGI Middleware

* Web Server 와 Application 을 연결시켜 줍니다.
* WSGI module + WSGI process = WSGI middleware
* Application 관점에서 Middleware 를 통해 App이 실행되므로, App을 실행시켜주는 Application Container 라고 할 수 있습니다.

#### 📌 Middleware 종류

* **Gunicorn**
* uWSGI
* CherryPy

### Application&#x20;
