Skip to content

Instantly share code, notes, and snippets.

@msoutopico
Created September 21, 2021 11:35
Show Gist options
  • Save msoutopico/5ac8d1ac3d7dfbce844cc5d3c22e2135 to your computer and use it in GitHub Desktop.
Save msoutopico/5ac8d1ac3d7dfbce844cc5d3c22e2135 to your computer and use it in GitHub Desktop.
post_md_doc.py
import requests
import os
import pathlib
import json
parent_dir_abspath = pathlib.Path(__file__).parent.absolute()
file = os.path.join(parent_dir_abspath, "doc.md")
url = 'https://www.mysite.com/doc/upload_md.php'
if os.path.exists(file):
with open(file, 'rb') as f:
r = requests.post(url, data = {"submit": "submit"}, files={'doc.md': f})
r = json.loads(r.text)
print(r['status'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment