Spaces:
Configuration error
Configuration error
Download backend/app/middleware/security_headers.py from Sivaneshakumar/sanjeevani-api: direct link, hf CLI and curl.
- Browser
- Download file 684 Bytes
-
https://huggingface.co/spaces/Sivaneshakumar/sanjeevani-api/resolve/main/backend/app/middleware/security_headers.py
- Command line
-
hf download hf://spaces/Sivaneshakumar/sanjeevani-api/backend/app/middleware/security_headers.py
-
curl -L -o security_headers.py https://huggingface.co/spaces/Sivaneshakumar/sanjeevani-api/resolve/main/backend/app/middleware/security_headers.py
684 Bytes
| from starlette.middleware.base import BaseHTTPMiddleware | |
| from starlette.requests import Request | |
| from starlette.responses import Response | |
| class SecurityHeadersMiddleware(BaseHTTPMiddleware): | |
| async def dispatch(self, request: Request, call_next) -> Response: | |
| response = await call_next(request) | |
| response.headers["X-Content-Type-Options"] = "nosniff" | |
| response.headers["X-Frame-Options"] = "DENY" | |
| response.headers["X-XSS-Protection"] = "1; mode=block" | |
| response.headers["Strict-Transport-Security"] = "max-age=31536000; includeSubDomains" | |
| response.headers["Referrer-Policy"] = "strict-origin-when-cross-origin" | |
| return response | |