From 9420b0c947c41d5732b2eee109e38e0512ef9976 Mon Sep 17 00:00:00 2001 From: Eli Uriegas Date: Thu, 16 Feb 2017 15:53:31 -0600 Subject: [PATCH] Adds file response object example --- examples/try_everything.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/try_everything.py b/examples/try_everything.py index e94ffc6e..f7191ecc 100644 --- a/examples/try_everything.py +++ b/examples/try_everything.py @@ -1,6 +1,8 @@ +import os + from sanic import Sanic from sanic.log import log -from sanic.response import json, text +from sanic.response import json, text, file from sanic.exceptions import ServerError app = Sanic(__name__) @@ -31,6 +33,10 @@ async def test_await(request): await asyncio.sleep(5) return text("I'm feeling sleepy") +@app.route("/file") +async def test_file(request): + return await file(os.path.abspath("setup.py")) + # ----------------------------------------------- # # Exceptions