[Flask] Flask Digest, Vol 7, Issue 11

Chukwudi Nwachukwu hsysinfo at gmail.com
Wed Jan 20 13:49:01 EST 2016


Found this somewhere online long time ago:
In the most common cases, request.data is going to be empty, because, as
stated in the docs, it's used as a fallback:

    request.data Contains the incoming request data as string in case it
came with a mimetype Flask does not handle.

    request.args : If you want the parameters in the URL
    request.form : If you want the information in the body (as sent by a
html POST form)
    request.values : If you want both



iChux™
http://bit.ly/iscrape
*Behind every no entry sign, there is a door.*

On 20 January 2016 at 18:00, <flask-request at python.org> wrote:

> Send Flask mailing list submissions to
>         flask at python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://mail.python.org/mailman/listinfo/flask
> or, via email, send a message with subject or body 'help' to
>         flask-request at python.org
>
> You can reach the person managing the list at
>         flask-owner at python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Flask digest..."
>
>
> Today's Topics:
>
>    1. need help on request.view_args (=?gb18030?B?z8TM7LXEt+c=?=)
>    2. Re: need help on request.view_args (David Lord)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 19 Jan 2016 16:00:48 +0800
> From: "=?gb18030?B?z8TM7LXEt+c=?=" <langslike at foxmail.com>
> To: "=?gb18030?B?Zmxhc2s=?=" <flask at python.org>
> Subject: [Flask] need help on request.view_args
> Message-ID: <tencent_4C4E614C71FEDA895FC71C62 at qq.com>
> Content-Type: text/plain; charset="gb18030"
>
> ------------------ ???? ------------------
> ???: "????";<langslike at foxmail.com>;
> ????: 2016?1?19?(???) ??3:47
> ???: "flask-request"<flask-request at python.org>;
>
> ??: help on request.view_args
>
>
>
> Hi
> I'm reading some web application code using flask, and the variable
> request.view_args confuses me: the url http://**?a=1 means that the
> associated request.args['a'] will be 1, how about view_args? how to set
> view_args for a request? and what's the general purpose of using it? I read
> the flask documentation ,but the description is too short .I googled but
> found most of the usage of view_args deals with pagination:
> http://flask.pocoo.org/snippets/44/
> def url_for_other_page(page):     args = request.view_args.copy()
>  args['page'] = page     return url_for(request.endpoint, **args)
> app.jinja_env.globals['url_for_other_page'] = url_for_other_page
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.python.org/pipermail/flask/attachments/20160119/ab93e613/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 2
> Date: Tue, 19 Jan 2016 18:12:27 -0800
> From: David Lord <davidism at gmail.com>
> To: flask at python.org
> Subject: Re: [Flask] need help on request.view_args
> Message-ID: <569EED0B.8090409 at gmail.com>
> Content-Type: text/plain; charset="utf-8"; Format="flowed"
>
> |view_args| is the list of arguments passed to the view, either captured
> from the url rule or set in the url defaults.
> http://flask.pocoo.org/docs/0.10/api/#flask.Request.view_args
>
> |@app.route('/hello/<name>') def hello(name): return 'Hello,
> {}'.format(name) |
>
> In this example, |view_args| will be |{'name': 'david'}| when you go to
> |/hello/david|.
>
> ?
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.python.org/pipermail/flask/attachments/20160119/06620ace/attachment-0001.html
> >
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> Flask mailing list
> Flask at python.org
> https://mail.python.org/mailman/listinfo/flask
>
>
> ------------------------------
>
> End of Flask Digest, Vol 7, Issue 11
> ************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20160120/231ae6a3/attachment.html>


More information about the Flask mailing list