When using HTMX framework with Python Flask, you have to be able to:

* serve a request as a HTML *fragment* if it's done by HTMX (via AJAX)
* server a request as a *full page* if it's done by the user (e.g. entered directly in the browser URL bar)

See [Single-page-application with fixed header/footer with HTMX, with browsing URL history](https://stackoverflow.com/questions/72914578/single-page-application-with-fixed-header-footer-with-htmx-with-browsing-url-hi/72914626#72914626) or [Allow Manual Page Reloading](https://juliensalinas.com/en/htmx-intercoolerjs-django-nlpcloud/#allow-manual-page-reloading) for more details.

**How to do this with the Flask template system?**

```
from flask import Flask, render_template, request
app = Flask("")
@app.route('/pages/<path>')
def main(path):
    htmx_request = request.headers.get('HX-Request') is not None
    return render_template(path + '.html', fullpage=not htmx_request)
app.run()

```

What's the standard way to output a full page (based on a parent template `pagelayout.html`):

```
{% extends "pagelayout.html" %}
{% block container %}
<button>Click me</button>
{% endblock %}

```

if `fullpage` is `True`, and just a HTML fragment:

```
<button>Click me</button>

```

if it is `False`?