Adds file response object example
This commit is contained in:
parent
dcfb7345f0
commit
9420b0c947
|
@ -1,6 +1,8 @@
|
||||||
|
import os
|
||||||
|
|
||||||
from sanic import Sanic
|
from sanic import Sanic
|
||||||
from sanic.log import log
|
from sanic.log import log
|
||||||
from sanic.response import json, text
|
from sanic.response import json, text, file
|
||||||
from sanic.exceptions import ServerError
|
from sanic.exceptions import ServerError
|
||||||
|
|
||||||
app = Sanic(__name__)
|
app = Sanic(__name__)
|
||||||
|
@ -31,6 +33,10 @@ async def test_await(request):
|
||||||
await asyncio.sleep(5)
|
await asyncio.sleep(5)
|
||||||
return text("I'm feeling sleepy")
|
return text("I'm feeling sleepy")
|
||||||
|
|
||||||
|
@app.route("/file")
|
||||||
|
async def test_file(request):
|
||||||
|
return await file(os.path.abspath("setup.py"))
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------- #
|
# ----------------------------------------------- #
|
||||||
# Exceptions
|
# Exceptions
|
||||||
|
|
Loading…
Reference in New Issue
Block a user