Scripting with Python

In situations when you need to use coding to handle special scenarios, you can use the Python scripting atom.

To create a Python scripting atom instance, you can use the following command.

generate view:script:default

The command will ask you the following information;

Instance name (pythonScript) :
Route (/pythonscript) :
Method (GET) :
File name ( :
Are all the inputs correct (yes) ?

The command will generate the following yaml code.

            route: /pythonscript
            method: GET 
            urn: python-script
                script: ""

The command will also generate a new file based on the inputs called ''. To assign response to the endpoint you can assign any value to the Output variable.

Output = "Works"

To test the endpoint you can use the following command;

curl -X GET http://localhost:5000/pythonscript

Which will return the following output;

    "success": true,
    "response": "Works",
    "error": null,
    "message": null