From 50a9075ecb90d14a00a53e77a0bd4a16d300ef59 Mon Sep 17 00:00:00 2001 From: Scoder12 <34356756+Scoder12@users.noreply.github.com> Date: Tue, 28 Jul 2020 17:32:12 -0700 Subject: [PATCH] Add files example --- examples/maqpy/files.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 examples/maqpy/files.py diff --git a/examples/maqpy/files.py b/examples/maqpy/files.py new file mode 100644 index 0000000..6937bfe --- /dev/null +++ b/examples/maqpy/files.py @@ -0,0 +1,14 @@ +from replit import maqpy + +app = maqpy.App(__name__) + + +@app.route("/") +def index(): + # Once a file is loaded once, it is cached in memory unless you pass the no_cache + # kwarg to the File constructor + f = maqpy.File(__file__) + # Tell the browser its just text, not a webpage + # we can edit the headers directly because the file is just a flask.Response object + f.headers["Content-Type"] = "text/plain" + return f