Flask: request vs Request

Andrew Z formisc at gmail.com
Sat Mar 10 22:43:07 EST 2018


hello,

 i'm playing with  Michael Grinberg's "Restful API with python and flask"
tutorial
<https://blog.miguelgrinberg.com/post/designing-a-restful-api-with-python-and-flask>
.

And i'm very much confused whats the difference between request and Request.
 the "request" is introduced @ the point he talks about "POST". Here is the
sample from the tutorial:

from flask import request
@app.route('/todo/api/v1.0/tasks', methods=['POST'])def create_task():
    if not request.json or not 'title' in request.json:
        abort(400)
    task = {
        'id': tasks[-1]['id'] + 1,
        'title': request.json['title'],
        'description': request.json.get('description', ""),
        'done': False
    }
    tasks.append(task)
    return jsonify({'task': task}), 201


the help system talks about somekind of LocalProxy class and then im
getting lost ....
The immediate trouble is that i don't see any methods for "request". ( Or,
at least, PyCharm can't find anything) and not sure what the "*r*equest" is
for and what i can do with it. Or should i use the "*R*equest"

Appreciate some guidance on the matter.



More information about the Python-list mailing list