# Running Flows outside Development Environment

**URL:** <https://discourse.nodered.org/t/running-flows-outside-development-environment/7278>\
**Category:** General\
**Created:** [26 January 2019 18:41 UTC](https://discourse.nodered.org/t/running-flows-outside-development-environment/7278 "2019-01-26T18:41:12Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![kxkayser](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kxkayser/32/6301_2.png) [@kxkayser](https://discourse.nodered.org/u/kxkayser)\
**Post date:** [26 January 2019 18:41 UTC](https://discourse.nodered.org/t/running-flows-outside-development-environment/7278/1 "2019-01-26T18:41:12Z")

</div>

Hi. I am brand new to NR and running on a Raspberry Pi. All of the tutorials I have read or watched show running flows within the development environment, usually by sending output to a Debug node. Surly the flows can be run outside this development environment but I don't see how. For example, I have a flow that turns an led on a gpio pin on and off. How can I run this either from a web browser or command line? Thanks for helping.

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [26 January 2019 19:57 UTC](https://discourse.nodered.org/t/running-flows-outside-development-environment/7278/2 "2019-01-26T19:57:52Z")

</div>

You can trigger a flow in Node-RED by using any input node. So it is possible to run your flow in a number of ways other than manually clicking on an inject node. It can be an HTTP request that arrives in your Node-RED instance, at a regular interval, at specific time of the day, after some TCP or UDP packet arrives, when an MQTT message arrives from the broker (to a topic that your input node subscribed of course), etc...

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [26 January 2019 20:11 UTC](https://discourse.nodered.org/t/running-flows-outside-development-environment/7278/3 "2019-01-26T20:11:47Z")

</div>

> [@kxkayser](#):
>
> running flows within the development environment,

When you are editing your flows, that is editing them in the Node-RED runtime. When you close your browser tab, the flows continue running in the runtime - there is no separate environment.

As @Andrei has described, there's a broad range of Input nodes to pick from to trigger your flows.

---

<div class="post-metadata">

**Author:** ![kxkayser](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kxkayser/32/6301_2.png) [@kxkayser](https://discourse.nodered.org/u/kxkayser)\
**Post date:** [26 January 2019 20:38 UTC](https://discourse.nodered.org/t/running-flows-outside-development-environment/7278/4 "2019-01-26T20:38:43Z")

</div>

Thanks for the quick response Andrei. I’m afraid I’m still confused about the run time environment. Are all the flows that have been deployed to the server always waiting for a trigger? Do I just build a web page that for example has buttons and send a message to a url? What would be the url for a particular flow? How do I name the flows in Node-RED? Sorry, I know these are novice questions but I want to make sure I will be able to do what I need before spending a lot of time developing flows. Maybe you can point me to a few examples where flows are used outside the development tool.

Thanks,

Ken Kayser

Tobaccoville, NC

[kxkayser@gmail.com](mailto:kxkayser@gmail.com)

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [26 January 2019 21:09 UTC](https://discourse.nodered.org/t/running-flows-outside-development-environment/7278/5 "2019-01-26T21:09:41Z")

</div>

Hi Ken, let me use the flow you mentioned in the OP to guide this reply. So, you have built a flow that turn on / off a led on your Rasberry PI. Now say you want to trigger this flow from the internet. There are several ways to do so but the easiest one is probably adding an HTTP in node to your flow (which demands adding also an HTTP out).

This is how your flow will look like:

 ![r-01](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/1/1bf4f2aae4e30d7086cbd26c8f60b0a93718afd6.png)

When you enter in any browser the URL for your flow the HTTP request will arrive to the configured endpoint and will trigger the flow.

In this example, I configured the endpoint http:127.0.0.1/myPI. You would use here the public address of your PI.

![r-02](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/6/662629b9a2dbda9d7014feb62db981833a280750.png)

This is what you will see in the debug panel, confirming the flow was triggered:  
 ![r-03](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/7d00463bf03fd8315b441fa030e059d5b85832dc.png)

Flow:

```auto
[{"id":"43f4472f.375598","type":"tab","label":"t1","disabled":false,"info":""},{"id":"a61e3b1b.e26698","type":"function","z":"43f4472f.375598","name":"Toggle LED","func":"msg.payload = \"Toggled LED status\";\nreturn msg;","outputs":1,"noerr":0,"x":430,"y":140,"wires":[["2fae1ed.e9f34e2","3054f2f7.8b547e"]]},{"id":"bf425e17.d1b37","type":"http in","z":"43f4472f.375598","name":"/mypi","url":"/mypi","method":"get","upload":false,"swaggerDoc":"","x":250,"y":140,"wires":[["a61e3b1b.e26698"]]},{"id":"2fae1ed.e9f34e2","type":"debug","z":"43f4472f.375598","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":650,"y":140,"wires":[]},{"id":"3054f2f7.8b547e","type":"http response","z":"43f4472f.375598","name":"","statusCode":"","headers":{},"x":620,"y":80,"wires":[]}]

```

You can use many other ways to trigger your flow. It is important to note that if you connect your PI to the internet it is advisable to take precautiions to make this safer. There are plenty of posts on hardening your PI for the internet.

---

<div class="post-metadata">

**Author:** ![kxkayser](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kxkayser/32/6301_2.png) [@kxkayser](https://discourse.nodered.org/u/kxkayser)\
**Post date:** [26 January 2019 22:09 UTC](https://discourse.nodered.org/t/running-flows-outside-development-environment/7278/6 "2019-01-26T22:09:29Z")

</div>

Hi Andrei. You provided an excellent explanation and example. Thanks you very much. So in your model flow, I take it there are 2 http requests: one input and one output. How do I associate my flow with the URL for this particular flow?

Best regards,

Ken Kayser

Tobaccoville, NC

[kxkayser@gmail.com](mailto:kxkayser@gmail.com)

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [26 January 2019 22:45 UTC](https://discourse.nodered.org/t/running-flows-outside-development-environment/7278/7 "2019-01-26T22:45:20Z")

</div>

You have to configure the `http in` node with the URL field. This will create the so called endpoint that will expose the service to the clients of your server (your PI running Node-RED is a full fledged server).

![r-04](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/1/1333683e271099b2d02931004559e91f15dbd92c.png)

You can create as many endpoints you wish for your use case. For instance, I changed the flow to add an endpoint to provide the clients with my computername using another endpoint (/mycomp).

 ![r-05](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/8/81e244b8f3a3b61ac57311733ea9e67330839b20.png)

Flow:

```auto
[{"id":"8f8f3bab.d42ad8","type":"tab","label":"http - toggle LED","disabled":false,"info":""},{"id":"e88d3ba2.7601f8","type":"function","z":"8f8f3bab.d42ad8","name":"Toggle LED","func":"msg.payload = \"Toggled LED status\";\nreturn msg;","outputs":1,"noerr":0,"x":370,"y":180,"wires":[["ff98df07.ef1df","1d7bf31e.07b00d"]]},{"id":"f4967954.77d768","type":"http in","z":"8f8f3bab.d42ad8","name":"/mypi","url":"/mypi","method":"get","upload":false,"swaggerDoc":"","x":190,"y":180,"wires":[["e88d3ba2.7601f8"]]},{"id":"88f9c32a.3c261","type":"debug","z":"8f8f3bab.d42ad8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":570,"y":240,"wires":[]},{"id":"ff98df07.ef1df","type":"http response","z":"8f8f3bab.d42ad8","name":"","statusCode":"","headers":{},"x":570,"y":180,"wires":[]},{"id":"a8c4353.8c875c8","type":"http in","z":"8f8f3bab.d42ad8","name":"/mycomp","url":"/mycomp","method":"get","upload":false,"swaggerDoc":"","x":200,"y":240,"wires":[["598d78de.47d738"]]},{"id":"598d78de.47d738","type":"change","z":"8f8f3bab.d42ad8","name":"Env computername","rules":[{"t":"set","p":"payload","pt":"msg","to":"COMPUTERNAME","tot":"env"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":240,"wires":[["ff98df07.ef1df","88f9c32a.3c261"]]},{"id":"1d7bf31e.07b00d","type":"debug","z":"8f8f3bab.d42ad8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":570,"y":140,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![kxkayser](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kxkayser/32/6301_2.png) [@kxkayser](https://discourse.nodered.org/u/kxkayser)\
**Post date:** [28 January 2019 00:22 UTC](https://discourse.nodered.org/t/running-flows-outside-development-environment/7278/8 "2019-01-28T00:22:41Z")

</div>

Your illustration has really cleared things up for me. Thanks again. I wasn’t thinking in an iot mode, more in a ui mode. Speaking of which, if you use the Dashboard nodes, where is the display viewed?

Regards,

Ken Kayser

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [28 January 2019 07:24 UTC](https://discourse.nodered.org/t/running-flows-outside-development-environment/7278/9 "2019-01-28T07:24:13Z")

</div>

The dashboard is another web application, so can be viewed on any browser on the same network as the Node-RED device.

---

<div class="post-metadata">

**Author:** ![kxkayser](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kxkayser/32/6301_2.png) [@kxkayser](https://discourse.nodered.org/u/kxkayser)\
**Post date:** [12 February 2019 19:16 UTC](https://discourse.nodered.org/t/running-flows-outside-development-environment/7278/10 "2019-02-12T19:16:18Z")

</div>

Hi Andrei,

You were so helpful in the past that I thought would try and impose on you again. I have tried the Forum but haven’t had any luck. I’ve been doing all sorts of things in NR and really love it.

```auto
I’m trying to run a Python program on the same Raspberry Pi as NR is running on. I can successfully do this with a simple test program using the Pythonshell node. However, when I try to run a program using some site libraries, it can’t find the imported modules. In particular I am trying to use some of the Adafruit CircuitPython modules. My program runs fine from the command line but when launching from node-red, I get errors such as “in <module> import board ImportError: module named board” where “board” is a module from CircuitPython. I have the normal shebang statement in my program (#!/usr/bin/env python3) and as I say, the program runs normally from the command line. Any ideas?

```

```auto
Thanks.

Ken Kayser

Tobaccoville, NC

kxkayser@gmail.com
```

---

<div class="post-metadata">

**Author:** ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)\
**Post date:** [12 February 2019 23:17 UTC](https://discourse.nodered.org/t/running-flows-outside-development-environment/7278/11 "2019-02-12T23:17:14Z")

</div>

Hello Ken,

I have absolutely no expeience on running python. I leave the question open as surely there are many in this forum that have the knowledge to advise you.

I see that you are using node `node-red-contrib-pythonshell`. Did you try some alternative like the `exec node` (possibly on spawn mode) or `node-red-node-daemon` ?

---

<div class="post-metadata">

**Author:** ![kxkayser](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kxkayser/32/6301_2.png) [@kxkayser](https://discourse.nodered.org/u/kxkayser)\
**Post date:** [12 February 2019 23:40 UTC](https://discourse.nodered.org/t/running-flows-outside-development-environment/7278/12 "2019-02-12T23:40:32Z")

</div>

Hi Andrew. Thanks for the reply. Yes, I was able to successfully launch my program with the exec node. Just wondering why the Pythonshell node didn’t work. NR is incredibly powerful.

Regards,

Ken Kayser

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [12 February 2019 23:53 UTC](https://discourse.nodered.org/t/running-flows-outside-development-environment/7278/13 "2019-02-12T23:53:46Z")

</div>

If the python shell didn’t work it’s worth opening an issue on the nodes github page so either the author can explain what you need to do or can hopefully fix the issue.

---

<div class="post-metadata">

**Author:** ![kxkayser](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kxkayser/32/6301_2.png) [@kxkayser](https://discourse.nodered.org/u/kxkayser)\
**Post date:** [13 February 2019 00:58 UTC](https://discourse.nodered.org/t/running-flows-outside-development-environment/7278/14 "2019-02-13T00:58:43Z")

</div>

Good idea, I’ll do it

Ken Kayser

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [13 February 2019 08:28 UTC](https://discourse.nodered.org/t/running-flows-outside-development-environment/7278/15 "2019-02-13T08:28:52Z")

</div>

> [@kxkayser](#):
>
> ust wondering why the Pythonshell node didn’t work.

I believe it is because the command it uses to run python does not work on your system. What command do you use to run python via an exec node?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [13 February 2019 10:13 UTC](https://discourse.nodered.org/t/running-flows-outside-development-environment/7278/16 "2019-02-13T10:13:07Z")

</div>

> [@Andrei](#):
>
> node-red-contrib-pythonshell

Another approach would be to disaggregate your Node-RED and Python processes. You could easily do that by wrapping your python code in a small server and making it listen either using an http API or via MQTT (or indeed both).

Here is a similar example of disaggregation:

[https://ianhinsdale.com/post/communicating-between-nodejs-and-python/](https://ianhinsdale.com/post/communicating-between-nodejs-and-python/)

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [13 February 2019 10:20 UTC](https://discourse.nodered.org/t/running-flows-outside-development-environment/7278/17 "2019-02-13T10:20:15Z")

</div>

Weirdly, despite similar naming, node-red-contrib-pythonshell does not seem to use `python-shell` which perhaps would have been more sensible.
