Chapter 9. Testing your Python function using the sample Flask application

You should test that your independent Python function works as expected before it goes into your application.

Prerequisites

Procedure

  1. In JupyterLab, open the run_flask.ipynb notebook file.
  2. Run all cells in the notebook by clicking CellRun All.

    This starts the Flask application.

Verification

  • Open a terminal in JupyterLab by clicking FileNewTerminal and run the following command:

    curl -X POST -H "Content-Type: application/json" --data '{"data" : "hello world"}' http://localhost:5000/prediction

    Alternatively, enter the following in a new notebook cell and run the cell.

    !curl -X POST -H "Content-Type: application/json" --data '{"data" : "hello world"}' http://localhost:5000/prediction

    If no changes have been made to the sample app, you see a response in the browser similar to {"prediction" : "not implemented"}.