I’ve created a script using scrapy to fetch some fields from a webpage. The url of the landing page and the urls of inner pages get redirected very often, so I created a middleware to handle that redirection. However, when I came across this post, I could understand that I need to return request in proc…
Tag: middleware
Get starlette request body in the middleware context
I have such middleware So the line body = await request.body() freezes all requests that have body and I have 504 from all of them. How can I safely read the request body in this context? I just want to log request parameters. Answer I would not create a Middleware that inherits from BaseHTTPMiddleware since …
How to stop having anonymous user in django
So I have a django project and there is one view(home view) which displays the posts of the followed users and that requires a user to be authenticated, if there is no user loged in, then the code returns a ‘AnonimousUser’ is not iterable error and I will like my code to redirect the anonymous use…