Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 

The Hello World Sample App

 

When you add an app in the Application Development Manager window, a simple "Hello World" sample app is also created.

The Hello World sample app adds a Hello World tab to JSA.

The following image shows an example of the Hello World tab that is added to JSA.

You can use this sample app as a simple template from which to build your own apps that require tabs. When you run the development environment script, the files that are described in the following table are added to your application development folder:

Table 1: Application Development Files

Files/Folders

Description

app

The root directory contains the following files:

qpylib contains the Python library files that your app uses to connect to the JSA API endpoints.

__init__.py a sample initialization file that creates a Flask instance, imports views from the views.py script and functions from the qpylib library.

views.py the main entry point into the web application. This file and the manifest.json file are the only files that are required in every app. Contains sample code for the Hello World app.

qradar_appfw_venv

Contains the Python virtual environment where the dependencies are installed.

__init__.py

Creates an instance of the Flask micro-framework that is used to serve content to JSA.

manifest.json

Describes to JSA what the sample Hello World app does.

run.py

Contains instructions to run the code that is stored in the app sub directory.

Manifest.json

The manifest.json file contains the following code:

{ "name":"Hello World", "description":"Application to display hello world", "version":"1.0", "uuid":"558d7935-f00b-42da-a278-c82abdb12b34", "areas": [ { "id":"QHelloWorld", "text":"Hello World", "description":"A Hello World app", "url":"index", "required_capabilities":["ADMIN"] } ], "dev_opts": [ { "console_ip":"" } ] }

The first four objects, name, description, version, and uuid provide basic app information.

The areas object describes the capabilities of the Hello World app. The JSA GUI Application Framework uses areas objects to describe new complete pages of the app. Areas objects are represented as tabs in the user interface.

The areas block contains the fields that are described in the following table:

Table 2: Areas Block

Name

Description

Value

id

The ID of the new tab

QHelloWorld

text

The name of the tab that is displayed in the user interface.

Hello World

description

A description of the tab that is displayed.

A Hello World app

url

Describes the route that is defined in the views.py script that JSA uses so it can display the "Hello, World!" text in the body of the new tab.

index

required_capabilities

Instructs JSA to display the Hello World tab only to users with Administrator privileges.

["ADMIN"]

The dev_opts block is used to provide the IP address of networked instance of JSA Console for testing purposes. This block is not required for this sample app.

Views.py

The views.py file contains the following code:

__author__ = 'IBM' from app import app @app.route('/') @app.route('/index') def index(): return "Hello, World!"

The code creates the default '/' and '/index' routes, both of which return a simple string. The index route is declared in the url field of the manifest.json file.

Note

You do not have to include the __author__ tag, but it is considered good practice to use it.

App Startup

When JSA starts your app, it calls the run.py and _init_.py scripts. The _init_.py file creates an instance of the Flask microframework environment that imports your views module. Your views modules define all the necessary endpoints and routes that serve content back to JSA.

__author__ = 'IBM' from flask import Flask app = Flask(__name__) from app import views

The run.py file creates a new Flask application (by starting the Flask web server), from the app directory.

__author__ = 'IBM' from app import app app.run(debug = True, host='0.0.0.0')

What Can You do with the Hello World Sample App?

You can use the Hello World sample app to test the JSA SDK in these ways:

  • Run the Hello World app locally.

  • If you have a test instance of JSA Console, you use the SDK to package and upload the Hello World app to it.

However, most importantly you can use the Hello World sample app files as a template to start developing your own JSA apps.