Python Eve contains filter Python Eve contains filter flask flask

Python Eve contains filter


You could use mongodb $regex operator, which is blacklisted by default in Eve (MONGO_QUERY_BLACKLIST = ['$where', '$regex']).

Add MONGO_QUERY_BLACKLIST = ['$where'] to your settings.py. Then you can query your API like this:

?where={"name": {"$regex": ".*foo.*"}}.

Be careful however. If you don't control the client, enabling regexes could potentially increase your API vulnerability.


I am not conversant with Eve myself. But looking at it's webpage seems like it exposes all of Flask's functionalities.

You need to be looking at this page in the documentation that talks about accessing the request data.

In your Flask app, define a method that accepts both POST and GET requests and then you can access foo by doing request.args.get('contains', '').

This is what I mean:

@app.route('/people', methods=['POST', 'GET'])def get_people():    search_key = request.args.get('contains', '')    #search for people containing 'foo' in your DB

Hope this gives you a starting point as to how to go about things.