| 1 | --- |
| 2 | title: "Accept" |
| 3 | description: "Content types htmx accepts from the server" |
| 4 | --- |
| 5 | |
| 6 | The `Accept` request header is set to `text/html, text/event-stream` on all htmx requests. |
| 7 | |
| 8 | This tells the server that htmx accepts both HTML and SSE streams. |
| 9 | |
| 10 | ## Example |
| 11 | |
| 12 | ```http |
| 13 | Accept: text/html, text/event-stream |
| 14 | ``` |
| 15 | |
| 16 | ```python |
| 17 | accept = request.headers.get('Accept') |
| 18 | if 'text/event-stream' in accept: |
| 19 | return stream_sse_events() |
| 20 | else: |
| 21 | return render_html() |
| 22 | ``` |