Skip to the content.

< Previous step: Installation

Create your first API: Hello World

We are going to use mfserv module to create a web API.

First, we need to launch mfserv service. You could launch mfserv individually, but the easiest way is to use a command that will launch all installed metwork services at once. As root user:

service metwork start

Note: if you don’t have the service command installed, you can use /etc/rc.d/init.d/metwork start instead

When it’s done, you can check that mfserv is working. Open this url in your browser: http://localhost:18868

You should see this:

alt text

Let’s create our first api. In MetWork Framework, we put our code in ‘plugins’. Thus, we are going to create our first plugin now.

When we installed mfserv module, the installer has created a ‘mfserv’ user. Let’s login as mfserv, and then create our plugin. We will call our plugin ‘hello’:

su - mfserv
cd ~
bootstrap_plugin.py create hello

Press enter several times to accept default values.

Now we need to launch our plugin. We launch it in ‘develop’ mode. In this mode, every modification to our plugin code will immediately launch a build, and thus you will see them in the browser.

# As mfserv user
cd ~/hello
make develop

Open this url in your browser: http://localhost:18868/hello. You should get this:

alt text

If you get a bad gateway error, just wait a few seconds for your plugin to start, and try again.

Next step: Put some code in your API >