Skip to content

Instantly share code, notes, and snippets.

@louis70109
Created August 10, 2022 15:57
Show Gist options
  • Save louis70109/bfc722790051807dac10458f234b0cf3 to your computer and use it in GitHub Desktop.
Save louis70109/bfc722790051807dac10458f234b0cf3 to your computer and use it in GitHub Desktop.
Format Markdown to Html style by Python and GitHub API
import requests
contents = ''
with open("a.md") as f:
contents = f.readlines()
sum = ''
for content in contents:
sum += content
print(sum)
res = requests.post(headers={
"Accept": "application/vnd.github+json",
"Authorization": "token GITHUB_KEY"
}, url="https://api.github.com/markdown",
json={"text": sum})
print(res.status_code)
print(res.text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment