O'Reilly logo

Instant Flask Web Development by Ron DuPlain

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Handling requests and responses (Simple)

This section will demonstrate how Flask handles incoming data on HTTP requests and how you can send responses.

Getting ready

Set aside the scheduling application and open a new Python file to explore Flask.

How to do it...

  1. At the core, Flask and Werkzeug provide request and response objects to represent incoming and outgoing data for your web application. Flask provides three different patterns for return values from your view functions:
    • string, which can optionally use a template engine (introduced later)
    • a response instance, an object with attributes representing HTTP response details
    • tuple of (string, status) or (string, status, http_headers), for convenience, such that you do not have to create a response ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required