Skip to the content.

< Previous step: Create your first API

Put some code in your API

Before starting

If something goes wrong and if you need debug information, please refer to the debug you app section.

Where is the code?

The code of our API is in the plugin ‘main’ directory.

# As mfserv user
cd ~/hello/main

You should see a file. The default bootstrap template for mfserv is in Python WSGI. But you could have choosen other templates like python-django or nodejs.

To show you that MetWork can work with several languages, we are not going to edit this plugin. We are going to create another plugin in nodejs.

# As mfserv user list

This command outputs the list of available plugin templates. Let’s choose node.

# As mfserv user
cd ~ create --template=node tutorial

Press enter several times to accept default values.

And then launch your new plugin.

cd tutorial
make develop

If you open http://localhost:18868/tutorial in your browser, you should see a ‘Hello World tutorial’ page.

The node template has bootstraped a nodejs express application. Let’s edit the code to make it more interesting.

In ~/tutorial/tutorial/server.js, Replace the line:

      res.send('Hello World tutorial!)


      var entry = req.param('q')
      res.send('Hello World tutorial! You have entered: ' + entry)

Now open http://localhost:18868/tutorial?q=foobar

This should output in your browser: ‘Hello World tutorial! You have entered: foobar’.

Next step: Monitor your application >