Curl domain and run script

Say I have a python script, how would I get that to run when the domain is curled?



You want curl to print hi! or whatever the one who curled?

In that case you need to use a webserver.

1 Like

Would flask work?

What you would want to do is use a command to run shell commands of the terminal.

You would first have to have the file on the website. Then you would need some code like this:

// php
echo exec("python3"); // output would be "hi!"
1 Like

Okay, but i’m not really sure about using PHP…

Is there any other methods available?

Would node work for you?

const { exec } = require("child_process");

exec("python3", (error, stdout, stderr) => {
    if (error) {
        console.log(`error: ${error.message}`);
    if (stderr) {
        console.log(`stderr: ${stderr}`);
    console.log(`stdout: ${stdout}`); // "hi!"
1 Like

No… Bash and python I can do. No idea about node

Hmm, ok, I’ll look into a way to do this in python.

1 Like

Try this:

import os
myCmd = 'python3'
os.system(myCmd) # outputs "hi!"
1 Like

Thanks, let me elaborate…

I want the user to curl the domain, and something should direct them to the running script. I could try with flask but is there any other way?

What do you mean? Do you mean the script should run on their local machine?

It should run on their machine without download. Which is possible with command line flags but are inconvenient…

Ah, you could just serve the python file in a static file server, then when the user curls the file you could do something like this:

curl | python3

yeah… it could work…

i’ve accepted @ihack2712’s solution, thanks all!

1 Like

Then why don’t you mark @ihack2712’s post as Solution? :joy:


lol :laughing: ,

goes to change everything