Why it is a thing
You absolutely shouldn't write files into the "local" Google App Engine (GAE) file system. Except for when you must (which means, you're probably too lazy not to (like me.)).
Once you have come to terms with this fact, the only thing you need to keep in mind is to include the leading /
in /tmp
. Took me only 3 hours to figure that out. I can recommend the following script to do so:
python
"""main"""
from pathlib import Path
from flask import Flask
app = Flask(__name__)
@app.route("/", methods=["GET"])
def main():
path = "/tmp/yolo.text"
fp = Path(path)
print("Writing", path)
fp.write_text(f"Hi there from {path}!")
print("Reading", path)
print(fp.read_text())
return "200"
if __name__ == "__main__":
main()
Notice the elaborate use of pathlib, which I totally came up with myself.