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
You have created an application from one of the S2I sample repositories by following the instructions in one of the following sections:
- You have created a separate function for your model by following the instructions in Saving your model as an independent Python function.
Procedure
-
In JupyterLab, open the
run_flask.ipynbnotebook file. Run all cells in the notebook by clicking Cell → Run All.
This starts the Flask application.
Verification
Open a terminal in JupyterLab by clicking File → New → Terminal and run the following command:
curl -X POST -H "Content-Type: application/json" --data '{"data" : "hello world"}' http://localhost:5000/predictionAlternatively, 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/predictionIf no changes have been made to the sample app, you see a response in the browser similar to
{"prediction" : "not implemented"}.