Deploy a flow using development server#

Experimental feature

This is an experimental feature, and may change at any time. Learn more.

Once you have created and thoroughly tested a flow, you can use it as an HTTP endpoint.

We are going to use the web-classification as an example to show how to deploy a flow.

Please ensure you have create the connection required by flow, if not, you could refer to Setup connection for web-classification.

Note: We will use relevant environment variable ({connection_name}_{key_name}) to override connection configurations in serving mode, white space in connection name will be removed directly from environment variable name. For instance, if there is a custom connection named ‘custom_connection’ with a configuration key called ‘chat_deployment_name,’ the function will attempt to retrieve ‘chat_deployment_name’ from the environment variable ‘CUSTOM_CONNECTION_CHAT_DEPLOYMENT_NAME’ by default. If the environment variable is not set, it will use the original value as a fallback.

The following CLI commands allows you serve a flow folder as an endpoint. By running this command, a flask app will start in the environment where command is executed, please ensure all prerequisites required by flow have been installed.

# Serve the flow at localhost:8080
pf flow serve --source <path-to-your-flow-folder> --port 8080 --host localhost

The expected result is as follows if the flow served successfully, and the process will keep alive until it be killed manually.


In visual editor, choose: img then choose format: img then in yaml editor: img

Test endpoint#

You could open another terminal to test the endpoint with the following command:

curl http://localhost:8080/score --data '{"url":""}' -X POST  -H "Content-Type: application/json"

You could open another terminal to test the endpoint with the following command:

Invoke-WebRequest -URI http://localhost:8080/score -Body '{"url":""}' -Method POST  -ContentType "application/json"

The development server has a built-in web page you can use to test the flow. Open ‘http://localhost:8080’ in your browser. img

Next steps#