第 9 章 使用示例 Flask 应用程序测试您的 Python 功能

您使用应用程序前,您应该测试独立 Python 功能是否可以按预期工作。

先决条件

流程

  1. 在 JupyterLab 中,打开 run_flask.ipynb 笔记本文件。
  2. CellRun All,在笔记本中运行所有单元。

    这将启动 Flask 应用程序。

验证

  • FileNewTerminal 在 JupyterLab 中打开一个终端,再运行以下命令:

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

    或者,在新的笔记本单元中输入以下内容并运行单元:

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

    如果没有对示例应用程序进行任何更改,您会在浏览器中看到类似 {"prediction" : "not implemented"} 的信息。