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 ...

Get Instant Flask Web Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.