7c180376d6
* Add Simple Server and CodeCov action * Remove token * Codecov to tox.ini * fix tox * Set coverage location * Add ignore to codecov * Try glob ignore * Setup CodeClimate * Allow coverage check to run * Change coverage check * Add codeclimate exclusions
22 lines
521 B
Python
22 lines
521 B
Python
from pathlib import Path
|
|
|
|
from sanic import Sanic
|
|
from sanic.exceptions import SanicException
|
|
from sanic.response import redirect
|
|
|
|
|
|
def create_simple_server(directory: Path):
|
|
if not directory.is_dir():
|
|
raise SanicException(
|
|
"Cannot setup Sanic Simple Server without a path to a directory"
|
|
)
|
|
|
|
app = Sanic("SimpleServer")
|
|
app.static("/", directory, name="main")
|
|
|
|
@app.get("/")
|
|
def index(_):
|
|
return redirect(app.url_for("main", filename="index.html"))
|
|
|
|
return app
|