I'm trying to update (append items) a Json file. The code below works when I run Flask locally on my machine, and also within Python Anywhere when I run it as a function. However the file is not updated when running it within Flask on Python Anywhere.
from pathlib import Path
import json
wordPath = Path(__file__).with_name('dictionary.json')
wordFile = open(wordPath)
wordDictionary = json.load(wordFile)
wordDictionary["Hello"] = "Hello World"
with open("dictionary.json", mode='w', encoding='utf-8') as jsonFile:
json.dump(wordDictionary, jsonFile)