Adding a functionality to consume the RESTful API that serves the model

Now we need to hit the API with the data on a click of the button. To achieve this, we need the flowing helper functions:

  • ByPostMethod: Accepts the URL as a String and returns the response as an InputStream.  This function takes the server URL string that we created using the Flask framework and returns the response from the server as an input stream:
InputStream ByPostMethod(String ServerURL) {      InputStream DataInputStream = null;     try {         URL url = new URL(ServerURL);          HttpURLConnection connection = (HttpURLConnection)         url.openConnection();         connection.setDoOutput(true);         connection.setDoInput(true);         connection.setInstanceFollowRedirects(false); connection.setRequestMethod( ...

Get Mobile Artificial Intelligence Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.