From 89368d224ee22f904c403ffcb1d307555627d2b3 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 11 Apr 2017 09:18:20 +0100 Subject: [PATCH] Modulize --- lantern/main.py | 15 ++++----------- lantern/route.py | 5 +++++ 2 files changed, 9 insertions(+), 11 deletions(-) create mode 100644 lantern/route.py diff --git a/lantern/main.py b/lantern/main.py index c17dff8..d64e9e6 100644 --- a/lantern/main.py +++ b/lantern/main.py @@ -1,18 +1,11 @@ from sanic import Sanic -from sanic.response import json, text -from sanic.exceptions import NotFound +from lantern.route import main_route + app = Sanic() -@app.route("/") -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.add_route(main_route, "/") + app.add_route(main_route, "/") app.run(host="0.0.0.0", port="8000") diff --git a/lantern/route.py b/lantern/route.py new file mode 100644 index 0000000..ceed5c1 --- /dev/null +++ b/lantern/route.py @@ -0,0 +1,5 @@ +from sanic.response import json + + +async def main_route(request, path=None): + return json({"hello": "world"})