I'm using Flask-Restless==1.0.0b1 with Flask-SQLAlchemy. What I like about it is that it provides JSON API 1.0 formatting out of the box.
My setup is the following:
I have a /v1/search that takes POST requests of multiple types
for each request to /v1/search I need to call a 3rd party. So I'm taking the request's JSON and passing it through a flask-marshmallow for validation, make the 3rd party call, and save a bunch of results with Flask-SQLAlchemy.
ideally, now I'd build a complex filtering flask-restless query and forward it to a model's endpoint. That way, I'd be getting the JSON API 1.0 formatting for free.
It would be something like the below. But the problem is that redirect doesn't seem to work with a REST api.
from flask import redirect
@app.route('/v1/search', methods=['POST'])
def search():
// do stuff
return redirect('/v1/<some_model>', 'filter[objects]={...}')
Is it possible to do this kind of redirection? Thank you
PS: You may be asking why I don't query the <some_model> directly and return the results. It's because I don't get the uniform JSON API 1.0 formatting. I could use marshmallow-jsonapi and marshmallow-sqlalchemy, but look https://github.com/marshmallow-code/marshmallow-jsonapi/issues/3 it's a lot more work and not really known how they work together with flask-restless.
Hello,
I'm using
Flask-Restless==1.0.0b1
withFlask-SQLAlchemy
. What I like about it is that it providesJSON API 1.0
formatting out of the box.My setup is the following:
/v1/search
that takesPOST
requests of multiple types/v1/search
I need to call a 3rd party. So I'm taking the request'sJSON
and passing it through aflask-marshmallow
for validation, make the 3rd party call, and save a bunch of results withFlask-SQLAlchemy
.flask-restless
query and forward it to a model's endpoint. That way, I'd be getting theJSON API 1.0
formatting for free.It would be something like the below. But the problem is that
redirect
doesn't seem to work with a REST api.Is it possible to do this kind of redirection? Thank you
PS: You may be asking why I don't query the
<some_model>
directly and return the results. It's because I don't get the uniformJSON API 1.0
formatting. I could usemarshmallow-jsonapi
andmarshmallow-sqlalchemy
, but look https://github.com/marshmallow-code/marshmallow-jsonapi/issues/3 it's a lot more work and not really known how they work together withflask-restless
.