Last active
March 9, 2017 20:17
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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