JSON Response

How to send a JSON response.

Use the respond() function (or the deprecated respond keyword) to return JSON data. This will also include the HTTP status code 200 OK.

Usage

respond(...)

Parameters:

  • Any datatype than can be JSON serialized:

    • dictionary.

    • list.

    • string.

    • integer.

    • float.

    • boolean.

    • tuple.

Example

@get('/greet/<name>'):
    respond('Hello ' + name)

Last updated