Jasper Blues
Jasper Blues

Reputation: 28786

Run remote python script

Its perhaps not the safest thing in the world to do, but assuming risks have been accounted for, what's the simplest way to load an run a python script that is http(s) hosted, from the local machine?

Upvotes: 2

Views: 70

Answers (1)

axblount
axblount

Reputation: 2662

# python 2
from urllib import urlopen
# python 3
from urllib.request import urlopen

page = urlopen('https://DANGEROUS').read()
exec(the_page)

EDIT: @jakekimds was right to point out that exec is more appropriate than eval here.

Upvotes: 3

Related Questions