Forums

execute local files from hosted site

Hi, I have a website hosted by pythonanywhere. 1) How to execute a .py file, residing in my local machine, from the hosted website? 2) If (1) is possible may I schedule execution of the .py file in local machine? A help will be much appreciated.

You could create a web app on PA, and use something on a web page to signal your local machine. Or you could send an email from the PA side, and have the local program check for emails regularly. Or you could use the absence, presence or contents of a file on the PA side as a signal, with the local program accessing the PA folder via FTP.

Once you have a solution for the communication, you should be able to setup a scheduled approach.

thanks for writing... actually i have a selenium webdriver in my local machine. i want to execute that from my web app on PA... tried this code on server side (it's not working)... execute "/home/.../sample.py"

I don't think I can help with this - anyone?

@ankur -- I don't think there's an easy way to do that. Essentially, your PythonAnywhere website is running as a program "out there" on the Internet, and you want it to control a program on your local machine.

Obviously, you don't want anyone else on the Internet to be able to run stuff on your machine :-) So you'd have to write some kind of thing that runs on your local machine that only allows authorised connections, and triggers the Selenium action that you want. That would require a fair amount of work.

Have you considered simply running Selenium on PythonAnywhere?

You are right Giles. It's a fair amount of work. Had to figure out something simple. Will let you know. Thanks anyways.

We'd love to hear what you come up with -- it sounds like an interesting problem.