Skip to content

Instantly share code, notes, and snippets.

@miklobit
Forked from fhightower/tiddly_wiki.py
Created September 26, 2021 02:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miklobit/aedda975c264329807b4900d07bd8d37 to your computer and use it in GitHub Desktop.
Save miklobit/aedda975c264329807b4900d07bd8d37 to your computer and use it in GitHub Desktop.
Making requests to tiddlywiki
"""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