Skip to content

Commit 9ec1cfb

Browse files
mmacphersonclaude
andauthored
docs: add Starlette example, reorder framework examples by lineage (#116)
Add a Starlette integration example to the README, timed with Starlette's 1.0 stable release. Reorder framework examples by lineage: ASGI family (Starlette → FastAPI → FastHTML) then WSGI family (Flask → Django). Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 00592ef commit 9ec1cfb

1 file changed

Lines changed: 29 additions & 14 deletions

File tree

README.md

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,35 @@ lucide_icon("user", stroke="#ff6b6b") # Hex colors work too
6060

6161
## Framework Integration Examples
6262

63+
### Starlette
64+
```python
65+
from starlette.applications import Starlette
66+
from starlette.responses import Response
67+
from starlette.routing import Route
68+
from lucide import lucide_icon
69+
70+
def icon(request):
71+
icon_name = request.path_params["icon_name"]
72+
svg = lucide_icon(icon_name, cls="icon", stroke="currentColor")
73+
return Response(svg, media_type="image/svg+xml")
74+
75+
app = Starlette(routes=[Route("/icons/{icon_name}", icon)])
76+
```
77+
78+
### FastAPI
79+
```python
80+
from fastapi import FastAPI
81+
from fastapi.responses import Response
82+
from lucide import lucide_icon
83+
84+
app = FastAPI()
85+
86+
@app.get("/icons/{icon_name}")
87+
def get_icon(icon_name: str, size: int = 24, color: str = "currentColor"):
88+
svg = lucide_icon(icon_name, width=size, height=size, stroke=color)
89+
return Response(content=svg, media_type="image/svg+xml")
90+
```
91+
6392
### FastHTML
6493
```python
6594
from fasthtml.common import *
@@ -114,20 +143,6 @@ def icon(name, **kwargs):
114143
return mark_safe(lucide_icon(name, **kwargs))
115144
```
116145

117-
### FastAPI
118-
```python
119-
from fastapi import FastAPI
120-
from fastapi.responses import Response
121-
from lucide import lucide_icon
122-
123-
app = FastAPI()
124-
125-
@app.get("/icons/{icon_name}")
126-
def get_icon(icon_name: str, size: int = 24, color: str = "currentColor"):
127-
svg = lucide_icon(icon_name, width=size, height=size, stroke=color)
128-
return Response(content=svg, media_type="image/svg+xml")
129-
```
130-
131146
## API Reference
132147

133148
### `lucide_icon()`

0 commit comments

Comments
 (0)