Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@paultopia
Last active March 28, 2017 18:34
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paultopia/23703b934c442a54808e245d9418545a to your computer and use it in GitHub Desktop.
Save paultopia/23703b934c442a54808e245d9418545a to your computer and use it in GitHub Desktop.
Easy pythonista script to use from dropbox iOS app share sheet to take dropbox link to python script and save it to pythonista filesystem. Also works with "raw" python scripts from github and gists.
import requests, appex
from urllib.parse import urlparse
url = appex.get_url().replace("dl=0", "dl=1")
r = requests.get(url)
filename = urlparse(url).path.rpartition("/")[-1].replace(".py", "-downloaded.py")
with open(filename, "wb") as outfile:
outfile.write(r.content)
print("script downloaded as " + filename)
@cclauss
Copy link

cclauss commented Mar 10, 2017

Could be a seven liner ;-) ...

  • Change line 7 to: outfile.write(requests.get(url).content)
  • Delete line 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment