From 10d4f2803a92605e6c74adbfa6fc8dc80c177e73 Mon Sep 17 00:00:00 2001 From: Adam Hopkins Date: Thu, 26 Jan 2023 18:06:13 +0200 Subject: [PATCH] Simple server to include autoindex --- sanic/simple.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sanic/simple.py b/sanic/simple.py index c575917e..6f6ebb7f 100644 --- a/sanic/simple.py +++ b/sanic/simple.py @@ -2,7 +2,6 @@ from pathlib import Path from sanic import Sanic from sanic.exceptions import SanicException -from sanic.response import redirect def create_simple_server(directory: Path): @@ -12,10 +11,8 @@ def create_simple_server(directory: Path): ) app = Sanic("SimpleServer") - app.static("/", directory, name="main") - - @app.get("/") - def index(_): - return redirect(app.url_for("main", filename="index.html")) + app.static( + "/", directory, name="main", autoindex=True, index_name="index.html" + ) return app