From ef47728842f4d664af70ecc28804093de9447d57 Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Sun, 15 Jul 2018 01:55:00 +0200 Subject: [PATCH] [mod] async file reading --- run.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run.py b/run.py index 2e584b5..6633791 100644 --- a/run.py +++ b/run.py @@ -214,8 +214,8 @@ async def api_new_job(request): @app.route('/') async def index(request): - return response.html(open("./templates/index.html", "r").read()) - # return await render_template("index.html", jobs=Job.select().order_by("id")) + async with aiofiles.open("./templates/index.html", mode="r") as index_template: + return response.html(await index_template.read()) if __name__ == "__main__":