archive
/
lantern
Archived
1
Fork 0

Add basic 404 handler

This commit is contained in:
Jake Howard 2017-04-11 09:01:04 +01:00
parent 94d3ee5d2a
commit d73a6b7730
1 changed files with 7 additions and 1 deletions

View File

@ -1,5 +1,6 @@
from sanic import Sanic
from sanic.response import json
from sanic.response import json, text
from sanic.exceptions import NotFound
app = Sanic()
@ -8,5 +9,10 @@ async def test(request):
return json({"hello": "world"})
@app.exception(NotFound)
def ignore_404s(request, exception):
return text("Page not found at {}".format(request.url), status=404)
def main():
app.run(host="0.0.0.0", port="8000")