Skip to content

Instantly share code, notes, and snippets.

@paultopia
Last active March 9, 2017 20:17
Show Gist options
  • Select an option

  • Save paultopia/a3e9c31da1d27a8ad9be7bf6b3df84a4 to your computer and use it in GitHub Desktop.

Select an option

Save paultopia/a3e9c31da1d27a8ad9be7bf6b3df84a4 to your computer and use it in GitHub Desktop.
Simple Pythonista script to convert markdown to docx using docverter and then save inside pythonista filesystem.
import requests
import appex
url = "http://c.docverter.com/convert"
filename = appex.get_file_path()
with open(filename, 'rb') as f:
r = requests.post(url, data={'to':'docx','from':'markdown'},files={'input_files[]':f})
if r.ok:
outfile = filename.rpartition('/')[-1].rpartition('.')[0] + '.docx'
with open(outfile, 'wb') as o:
o.write(r.content)
print("success!" + outfile)
else:
print('request failed: ' + r.status_code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment