Simple server to include autoindex
This commit is contained in:
parent
fa6dbddf69
commit
10d4f2803a
|
@ -2,7 +2,6 @@ from pathlib import Path
|
||||||
|
|
||||||
from sanic import Sanic
|
from sanic import Sanic
|
||||||
from sanic.exceptions import SanicException
|
from sanic.exceptions import SanicException
|
||||||
from sanic.response import redirect
|
|
||||||
|
|
||||||
|
|
||||||
def create_simple_server(directory: Path):
|
def create_simple_server(directory: Path):
|
||||||
|
@ -12,10 +11,8 @@ def create_simple_server(directory: Path):
|
||||||
)
|
)
|
||||||
|
|
||||||
app = Sanic("SimpleServer")
|
app = Sanic("SimpleServer")
|
||||||
app.static("/", directory, name="main")
|
app.static(
|
||||||
|
"/", directory, name="main", autoindex=True, index_name="index.html"
|
||||||
@app.get("/")
|
)
|
||||||
def index(_):
|
|
||||||
return redirect(app.url_for("main", filename="index.html"))
|
|
||||||
|
|
||||||
return app
|
return app
|
||||||
|
|
Loading…
Reference in New Issue
Block a user