Skip to content

Commit e949d26

Browse files
committedMar 26, 2025
update readme
1 parent d8cd9f3 commit e949d26

10 files changed

+80
-2
lines changed
 

‎README.md

+56-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
---
1818

19-
**Documentation**:
20-
2119
**Source Code**: <a href="https://github.com/developmentseed/stac-fastapi-html-middleware" target="_blank">https://github.com/developmentseed/stac-fastapi-html-middleware</a>
2220

2321
---
@@ -36,6 +34,36 @@ The `HTMLRenderMiddleware` is designed to intercept responses from stac-fastapi
3634
- the user set `f=html` query-parameter
3735
- `Accept: text/html` request's headers is the highest *priority*
3836

37+
```bash
38+
# regular request - return JSON document
39+
$ curl http://127.0.0.1:8000 -s -D - -o /dev/null
40+
HTTP/1.1 200 OK
41+
date: Wed, 26 Mar 2025 11:16:18 GMT
42+
server: uvicorn
43+
content-length: 3001
44+
content-type: application/json
45+
46+
# Ask for html with `Accept` header - return HTML document
47+
$ curl http://127.0.0.1:8000 -s -D - -o /dev/null -H 'accept: text/html'
48+
HTTP/1.1 200 OK
49+
date: Wed, 26 Mar 2025 11:15:38 GMT
50+
server: uvicorn
51+
content-length: 3560
52+
content-type: text/html
53+
54+
# Ask for html with `f=html` QueryParameter - return HTML document
55+
$ curl http://127.0.0.1:8000\?f\=html -s -D - -o /dev/null
56+
HTTP/1.1 200 OK
57+
date: Wed, 26 Mar 2025 11:16:03 GMT
58+
server: uvicorn
59+
content-length: 3569
60+
content-type: text/html
61+
```
62+
63+
This middleware will also intercept the openapi document from stac-fastapi application to enhance the schemas by adding `f=html` query-parameter and `Accept: text/html` available headers.
64+
65+
<img width="800" alt="Screenshot 2025-03-25 at 3 16 44 PM" src="https://github.com/user-attachments/assets/07b53933-fbfd-4ba1-b654-6f2d72a2334b" />
66+
3967
## How
4068

4169
```python
@@ -51,6 +79,32 @@ api = StacApi(
5179
)
5280
```
5381

82+
:warning: You should place the `HTMLRenderMiddleware` before any `compression` middleware in the `middlewares` stack
83+
84+
```python
85+
# NOK
86+
api = StacApi(
87+
...
88+
middlewares=[
89+
Middleware(BrotliMiddleware),
90+
Middleware(HTMLRenderMiddleware),
91+
],
92+
)
93+
# OK
94+
api = StacApi(
95+
...
96+
middlewares=[
97+
Middleware(HTMLRenderMiddleware), # <-- Put the HTML Render middleware before the compression middleware
98+
Middleware(BrotliMiddleware),
99+
],
100+
)
101+
```
102+
103+
## HTML documents
104+
105+
See [docs/pages.md](docs/pages.md) for HTML preview
106+
107+
54108
## Contribution & Development
55109

56110
See [CONTRIBUTING.md](https://github.com/developmentseed/stac-fastapi-html-middleware/blob/main/CONTRIBUTING.md)

‎docs/img/collection.png

343 KB
Loading

‎docs/img/collections.png

205 KB
Loading

‎docs/img/conformance.png

358 KB
Loading

‎docs/img/item.png

285 KB
Loading

‎docs/img/items.png

479 KB
Loading

‎docs/img/landing.png

186 KB
Loading

‎docs/img/queryables.png

163 KB
Loading

‎docs/img/search.png

476 KB
Loading

‎docs/pages.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
### Landing
3+
![](img/landing.png)
4+
5+
### Conformances
6+
![](img/conformance.png)
7+
8+
### Queryables
9+
![](img/queryables.png)
10+
11+
### Collections
12+
![](img/collections.png)
13+
14+
### Collection
15+
![](img/collection.png)
16+
17+
### Items Collection
18+
![](img/items.png)
19+
20+
### Item
21+
![](img/item.png)
22+
23+
### Search
24+
![](img/search.png)

0 commit comments

Comments
 (0)
Please sign in to comment.