Connect UI created in Bolt cloud to the python Code

Is it possible to connect the User interface created in the Bolt cloud to the python code written in the ubuntu terminal?
for example:-assume a program to on and off a LED is written in terminal and buttons for the same is designed in the configuration of the bolt cloud.Then how can connect this configuration to the program in terminal so that when I press the button for ON the light in the cloud the python program in terminal runs!?

Hi @11170021,

I don’t know why do you want trigger your python code from the Bolt Cloud control page. So triggering your python code form Bolt cloud could be costly. You will require the following services.

  1. A server from Cloud provider - For example server from DigitalOcean or AWS etc.

  2. Then a domain from domain name provider.

  3. SSL certificate (https) for the domain. For example: https://www.mywebsite.com . Because you can not do any unsecured request from the Bolt Cloud.

  4. Make a webapp and build the API. You can use the flask framework for building your python api. https://flask.palletsprojects.com/en/1.1.x/quickstart/

  5. After building the Webapp, link your Webapp to a server using Nginx.

  6. For example: suppose you build the api with name /trigger_on. Then the url will be https://www.mywebsite.com/trigger_on

  7. Now you will attach your function to switch on the led to trigger_on api.

  8. Now in your html code of Bolt Cloud, you will trigger your api using the ajax code https://www.w3schools.com/js/js_ajax_intro.asp

  9. Once you trigger the https://www.mywebsite.com/trigger_on api, it will execute the attached function to it.

Check this video about flask web app https://www.youtube.com/watch?v=BUmUV8YOzgM
Do let me know in case you need any other information.

Sir, I am doing a project on weather reporting using Bolt IoT, and i had written the code in my ubuntu terminal. I came across a project in the hackster page which triggers the python code in the terminal by the html UI designed in the Bolt cloud.
Here is the project,
https://www.hackster.io/srishtikrastogi/automated-light-monitoring-system-4baa97
in this the AUTO functionality triggers the python code.
So that i thought, why i can’t make my project also as an application and your information is so valuable. Thank you.

1 Like

Hi @11170021,

Please read through the whole explanation given in the hackster project.

The python code is continuously running in the background, setting the pwm value of pin 0.
The Cloud code on the other hand control pins 1 and pin 2.

The project uses a hardware multiplexer built using 2 and gates, 1 not gate and 1 or gate, to use pin 2 to control select which pin (0 or 1) controls the LED.

In normal control mode, pin 1 controls the LED, in auto control mode, pin 0 controls the LED.

No triggering of python code takes place. The control of the LED is switched in hardware.