Simple server to include autoindex

This commit is contained in:
Adam Hopkins 2023-01-26 18:06:13 +02:00
parent fa6dbddf69
commit 10d4f2803a
No known key found for this signature in database
GPG Key ID: 9F85EE6C807303FB

View File

@ -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