Re: [flask] passing arguments to views
- From:
- Ryo Mikami
- Date:
- 2011-11-19 @ 13:26
Hi Jandos, you can pass it via decorator like this.
def create_object_from_request_json(function):
@functools.wraps(function)
def _create_object_from_request_json():
# make client_info from request.json...
return function(client_info)
return _create_object_from_request_json
@app.route('/add_client, methods=['GET', 'POST'])
@create_object_from_request_json
def add_client(client_info):
#add client to db via sqlalchemy...
On Sat, Nov 19, 2011 at 9:06 PM, Jandos Khalik <jandos.kh@gmail.com> wrote:
> Is it possible to construct object from request.json and
> pass it as an argument to the view, which was called by client?
> For example, I would like send client information as json to
> the server, and on the server have:
> @app.route('/add_client, methods=['GET', 'POST'])
> def add_client(client_info)
> #add client to db via sqlalchemy...
> pass
>
>