DEV Community

loading...
Cover image for Execute WayScript Programs Via WayScript API
WayScript

Execute WayScript Programs Via WayScript API

Derrick Sherrill
Software developer who sometimes makes videos
・2 min read

Introduction

One of the biggest benefits of WayScript is its versatility and seamless integration between different programs and platforms. In this tutorial, we’ll learn how to use these to our advantage by executing a program built in WayScript outside of the website. We can do this by writing our own Python code and utilizing the WayScript Python API. Keep reading to learn more!

Building our Script

The example script we’ll use simply passes a query parameter using the HTTP Trigger module, formats it using the Python module, and then writes the values to an SQL table with the SQL module. If for some reason the user doesn’t want to visit the URL produced from the HTTP Trigger or run the program through WayScript, they have the ability to execute it using Python on their own computer.

The first step in executing this script through Python is installing the WayScript library using the pip installer. The code for this step is: pip3 install wayscript. Now, it’s time to import WayScript so that the user can gain access to the WayScript clients. The next line of code activates the client, so that Python can execute the specified WayScript program. So far, your code should look something like this.

tutorial step #1

In our example script we’ve included the query parameter “sample_list.” This query parameter can also be passed in the execution of the script through Python. For this line of code, “q” should be set equal to the query parameter and the expected values. Next, the program ID must be specified in the code. This ID can be found at the end of the WayScript URL for the script. Finally, to run the script simply use the wayscript.run and include the ID and parameters in parentheses. If this is a bit confusing, the below image shows the appropriate code for all of these steps.

tutorial step #1

This is only one simple function of using WayScript’s Python API, but it demonstrates the versatility of WayScript that can’t always be found with other sites. Our Python API has several other features, including the ability to execute programs with password protections and more. To see these, just visit the link at the end of this article.

Conclusion

Questions about this script or anything else? Join our discord. We're always around to help. To see the full API and its features, just find it here.

Discussion (0)