Locally execute python file that is located on a web server -


i working on open-source project called rubberband open source project allows title says. locally execute python file located on web server, have run problem. if comma located in string (etc. "http:"), return error.

''' rubberband version 1.0.1 'indigo-charlie' http://www.lukeshiels.com/rubberband  change-log:  changed error messages. changed whole code 1 function, rather three. changed importing required libraries 1 line instead of 2  ''' #edit below line  import httplib, urlparse  def executefromurl(url):     if (url == none):         print "!# rubberband_error: no url specified #!"     else:         core = none         good_codes = [httplib.ok, httplib.found, httplib.moved_permanently]      host, path = urlparse.urlparse(url)[1:3]     try:         conn = httplib.httpconnection(host)         conn.request('head', path)         core = conn.getresponse().status      except standarderror:         core = none      if(core in good_codes):         exec(url)     else:         print "!# rubberband_error: file not exist on webserver #!" 

rubberband in 3 lines without error checking:

import requests def execute_from_url(url):      exec(requests.get(url).content) 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -