0

I use my Azure function to return a certain output after passing an HTML trigger. The webpage prints out basic output, like Hello {name}.

I would like to pass this output into an HTML file and display it via a separate HTML file. Essentially, I want to extract what my helloworld.azureapp.com?name={name} returns and push it into a JS variable in an HTML file.

How would I do this?

Note that the Azure function is written in Python.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Abhirup Ghosh
  • 29
  • 1
  • 7

1 Answers1

0

If I understand correctly, what you're looking for is to make your web application send a GET request to your azure function endpoint and store the response you get back in a javascript variable.

You should treat the responses from an Azure function HTTP trigger just like any standard response from any API.

Instead of writing all js code in native HTML files, it is recommended you pick a simple web application framework.

For python, you can try Django or Flask (introductory tutorials here).

The code that calls your Azure function endpoint helloworld.azureapp.com?name={name} could be in your web application (using the requests module in python). Tutorial on how to make web requests in python here.

Once you get back the response for that request, you can do further processing with the values you get back.

Depending on your web application framework, you could do many things.

Some of them are:

  1. Save it in a hidden field and get value in JavaScript.

  2. Render the received values to element in page on server side and show it.

Rithin Chalumuri
  • 1,739
  • 7
  • 19