You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Note: Overriding the `Server` Header in Uvicorn-based Frameworks
29
29
30
-
If you're using Uvicorn as the ASGI server (commonly used with frameworks like FastAPI, Starlette, and others), Uvicorn automatically injects a `Server: uvicorn` header into all HTTP responses by default. This can lead to multiple `Server` headers when using `Secure.py` to set a custom `Server` header.
30
+
If you're using Uvicorn as the ASGI server (commonly used with frameworks like FastAPI, Starlette, and others), Uvicorn automatically injects a `Server: uvicorn` header into all HTTP responses by default. This can lead to multiple `Server` headers when using `secure` to set a custom `Server` header.
31
31
32
32
To prevent Uvicorn from adding its default `Server` header, you can disable it by passing the `--no-server-header` option when running Uvicorn, or by setting `server_header=False` in the `uvicorn.run()` method:
**[Dash](https://dash.plotly.com/)** is a Python framework for building interactive data apps and dashboards, built on top of Plotly.js, React, and Flask.
177
+
178
+
### Middleware Example
179
+
180
+
```python
181
+
import dash
182
+
from dash import html
183
+
from secure import Secure
184
+
185
+
secure_headers = Secure.with_default_headers()
186
+
187
+
app = dash.Dash(__name__)
188
+
server = app.server
189
+
190
+
app.layout = html.Div("Hello Dash!")
191
+
192
+
193
+
@server.after_request
194
+
defadd_security_headers(response):
195
+
secure_headers.set_headers(response)
196
+
return response
197
+
```
198
+
199
+
#### Alternative: WSGI middleware
200
+
201
+
```python
202
+
import dash
203
+
from dash import html
204
+
from secure import Secure
205
+
from secure.middleware.wsgi import SecureWSGIMiddleware
**[Shiny](https://shiny.posit.co/py/)** is a fully reactive framework for building rich, interactive web apps in pure Python—without needing to learn JavaScript or front-end frameworks.
619
+
620
+
### Middleware Example
621
+
622
+
```python
623
+
from secure import Secure
624
+
from secure.middleware import SecureASGIMiddleware
0 commit comments