Skip to content

Commit

Permalink
Optional whitenoise
Browse files Browse the repository at this point in the history
  • Loading branch information
jpsca committed Oct 19, 2024
1 parent f609c01 commit 1f6fd5a
Show file tree
Hide file tree
Showing 6 changed files with 298 additions and 263 deletions.
11 changes: 10 additions & 1 deletion docs/content/guide/css_and_js.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ The tags above will not work if your application can't return the content of tho

For that reason, JinjaX includes WSGI middleware that will process those URLs if you add it to your application.

**This is not needed if your components doesn't use static assets or if you serve them by other means.**

```py
from flask import Flask
from jinjax import Catalog
Expand All @@ -138,7 +140,14 @@ app.wsgi_app = catalog.get_middleware(
)
```

The middleware uses the battle-tested [Whitenoise library](http://whitenoise.evans.io/) and will only respond to the *.css* and *.js* files inside the component(s) folder(s). You can configure it to also return files with other extensions. For example:
The middleware uses the battle-tested [Whitenoise library](http://whitenoise.evans.io/) and will only respond to the *.css* and *.js* files inside the component(s) folder(s).
Yo must install it first:

```bash
pip install jinjax[whitenoise]
```

Then, you can configure it to also return files with other extensions. For example:

```python
catalog.get_middleware(app, allowed_ext=[".css", .js", .svg", ".png"])
Expand Down
6 changes: 0 additions & 6 deletions package-lock.json

This file was deleted.

Loading

0 comments on commit 1f6fd5a

Please sign in to comment.