|
1 | 1 | ## stac-fastapi HTML middleware
|
| 2 | + |
| 3 | +<p align="center"> |
| 4 | + <img width="500" src="https://github.com/user-attachments/assets/f243a238-5ba7-44da-963a-cd865578c2a5"/> |
| 5 | + <p align="center">stac-fastapi middleware to encode responses into HTML documents</p> |
| 6 | +</p> |
| 7 | +<p align="center"> |
| 8 | + <a href="https://github.com/developmentseed/stac-fastapi-html-middleware/actions?query=workflow%3ACI" target="_blank"> |
| 9 | + <img src="https://github.com/developmentseed/stac-fastapi-html-middleware/workflows/CI/badge.svg" alt="Test"> |
| 10 | + </a> |
| 11 | + <a href="https://github.com/developmentseed/stac-fastapi-html-middleware/blob/main/LICENSE" target="_blank"> |
| 12 | + <img src="https://img.shields.io/github/license/developmentseed/stac-fastapi-html-middleware.svg" alt="License"> |
| 13 | + </a> |
| 14 | +</p> |
| 15 | + |
| 16 | + |
| 17 | +--- |
| 18 | + |
| 19 | +**Documentation**: |
| 20 | + |
| 21 | +**Source Code**: <a href="https://github.com/developmentseed/stac-fastapi-html-middleware" target="_blank">https://github.com/developmentseed/stac-fastapi-html-middleware</a> |
| 22 | + |
| 23 | +--- |
| 24 | + |
| 25 | +## Install |
| 26 | + |
| 27 | +```bash |
| 28 | +$ git clone https://github.com/developmentseed/stac-fastapi-html-middleware.git |
| 29 | +$ cd stac-fastapi-html-middleware |
| 30 | +$ python -m pip install -e . |
| 31 | +``` |
| 32 | + |
| 33 | +## What |
| 34 | + |
| 35 | +The `HTMLRenderMiddleware` is designed to intercept responses from stac-fastapi application (`json` or `geojson`) and to encode it to HTML responses when: |
| 36 | +- the user set `f=html` query-parameter |
| 37 | +- `Accept: text/html` request's headers is the highest *priority* |
| 38 | + |
| 39 | +## How |
| 40 | + |
| 41 | +```python |
| 42 | +from starlette.middleware import Middleware |
| 43 | + |
| 44 | +from stac_fastapi.api.app import StacApi |
| 45 | +from stac_fastapi.html.middleware import HTMLRenderMiddleware |
| 46 | + |
| 47 | +api = StacApi( |
| 48 | + middlewares=[ |
| 49 | + Middleware(HTMLRenderMiddleware), |
| 50 | + ], |
| 51 | +) |
| 52 | +``` |
| 53 | + |
| 54 | +## Contribution & Development |
| 55 | + |
| 56 | +See [CONTRIBUTING.md](https://github.com/developmentseed/stac-fastapi-html-middleware/blob/main/CONTRIBUTING.md) |
| 57 | + |
| 58 | +## License |
| 59 | + |
| 60 | +See [LICENSE](https://github.com/developmentseed/stac-fastapi-html-middleware/blob/main/LICENSE) |
| 61 | + |
| 62 | +## Authors |
| 63 | + |
| 64 | +Created by [Development Seed](<http://developmentseed.org>) |
| 65 | + |
| 66 | +## Changes |
| 67 | + |
| 68 | +See [CHANGES.md](https://github.com/developmentseed/stac-fastapi-html-middleware/blob/main/CHANGES.md). |
| 69 | + |
0 commit comments