Introduction
We're building a rapid platform for developers called WayScript. We'd love your feedback.
WayScript makes it easy to run python code whenever you access a url. By allowing access to an http trigger, we can activate entire workflows at the visit of a specific url. Whether you're building a system that pulls the most current information from a database, or something simple like a randomized password generator, I hope you see the power in this functionality.
Running a Script when Visiting a URL
We're able to activate a lot more than just an HTTP response whenever we visit a url. We can activate entire workflows! The possibilities are limitless due to our large number of modules you can integrate, but let's keep it simple in this tutorial and look at how we can automate running python whenever you visit a URL.
To get started, we'll need to place in a HTTP trigger and activate it. This will provide a URL for us to run our script.
The endpoint will be provided in the settings and we can choose to password protect this if we want to.
Working with Python
Next, we can drag in the modules and create the workflow that we want to execute whenever someone visits this url. We'll place a python module below the http trigger
Once we place the python module, we have access to the built in platform editor. Let's create something like a password generator, that we'll return the result of to a webpage. Our code might look something like this:
import string from random import * characters = string.ascii_letters + string.digits + string.punctuation password = "".join(choice(characters) for x in range(randint(8,16))) print(password) variables['password'] = password
We're just creating a randomized string here to pass to a webpage, but this could be anything. We could pull from databases, the internet, or anywhere else and process it all with this one python module.
Creating a Webpage & Response
Once we pass the output using the variables dictionary in the last line of python code above, we can access it all throughout our script. We'll drag this variable into our html code and then pass this html as a response with a configuration like this:
Hope you enjoyed this a video can also be found on our website. Also, WayScript is in Beta and Signup is currently free for all of our friends at DEV.to.
Top comments (0)