Creating a first Hello World Application

How to Create a Hello World Application

This page takes you through, in the simplest terms how to create a Hello World Application in Lolo that you send a HTTP GET to and receive a response. The capabilities and features of Lolo are covered in the most minimal terms here just to get you started.

When you first log into Lolo, you are, by default, in the Application development section of the Lolo IDE that allows you to create (and delete) Applications.

When creating an App(lication) you are presented with options to name and describe the App - which can be renamed later and from there you are presented with the App canvas.

The App canvas has two control sets:

  • Function Palette accessed by the + in the upper left
  • Function Controls in the bottom right

Using the Function Palette, add a HTTP Trigger Library Function and a Log Library Function. Using the Function Controls add a New Function,

Connect up the Functions as shown below.

Function Configuration

Configure the Functions as follows.

HTTP TRIGGER

Under the Parameters sub-tab, the Method, Path, Async and Type need to be configured as shown in the following diagram.

The Async option is important as you'll use the emit() method in the inline JavaScript function to send a JSON response.

Under the Options sub-tab, change the Name as follows to make the App a bit more readable.

Note down the URL from External URL sub-tab to know where to perform your GET against.

New Function

New Function is an inline JavaScript function is where the main body of this very simple application is. This New Function won't have an output port because it will use emit() to send the JSON response. Configure the New Function under Ports sub-tab as follows.

And set the Name and Description under the Options sub-tab to make the App more readable as follows.

In the Handler tab add the following code

exports.handler = async(ev, ctx) => {
  const { route, state, emit, log } = ctx;

  let count = state.get('count') || 0;
  count++;
  state.set('count', count);

  const body = { response: 'hello cruel world', count };

  emit('response', { statusCode: '200', body });
};

Your completed App should look something like the following.

From there you can "Save and Deploy" your first App. Check the Logs tab to view your App deploying and use your web browser or PostMan to test using the External URL as shown below.


What’s Next