Created
August 14, 2019 12:20
-
-
Save fhightower/e617b70a8854e4d53c7768c0ef8c78a7 to your computer and use it in GitHub Desktop.
Making requests to tiddlywiki
This file contains 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
"""Code showing how to create a tiddler in tiddly wiki using python. I was not able to get this working without the "X-Requested-With" header.""" | |
import requests | |
TIDDLY_WIKI_URL = 'https://localhost:8080' | |
TIDDLY_WIKI_REQUEST_HEADERS = { | |
# this "X-Requested-With" header is the key to making these requests work | |
'X-Requested-With': 'TiddlyWiki', | |
'Content-Type': 'application/json' | |
} | |
tiddler_data = { | |
'title': 'foo', | |
'text': 'bar' | |
} | |
url_path = f'{TIDDLY_WIKI_URL}/recipes/default/tiddlers/{tiddler_title}' | |
response = requests.put(url, data=tiddler_data, headers=TIDDLY_WIKI_REQUEST_HEADERS) | |
print(response) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment