[Flask] Is there a centralized way .. to preprocess URL requests headed to routes.py?

Gabor Szabo gabor at szabgab.com
Fri Jul 3 01:04:37 EDT 2020


On Fri, Jul 3, 2020 at 2:23 AM flaskee via Flask <flask at python.org> wrote:

> routes.py will have possibly many decorators for different pages of a
> webpage.
>
> I'm wondering if there is one central place to inspect *any* request made
> against a flask site;
> before it gets to each decorator?
>
> The hacking attacks now adays are many and varied --and it would be nice to
> be able to log or pre-process ALL page requests; to look for SQL attacks,
> URL injection attacks, etc.
> *Even if the pages being requested are not really on your site;* and they
> are just wildly trying things.
>
> Just a way to see/touch EVERYTHING before it hits the decorators.
>
> Is there a way to do this?
>
> Thanks
>
>
Do you mean something like this that runs before every request?

- @app.before_request
- def before_request():
-     app.logger.info("before_request")


-- 
Gabor Szabo                    http://szabgab.com/
Code Maven                     http://code-maven.com/flask
<http://code-maven.com/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20200703/faa8e422/attachment.html>


More information about the Flask mailing list