archive
/
lantern
Archived
1
Fork 0
This commit is contained in:
Jake Howard 2017-04-11 09:18:20 +01:00
parent d73a6b7730
commit 89368d224e
2 changed files with 9 additions and 11 deletions

View File

@ -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, "/<path>")
app.add_route(main_route, "/")
app.run(host="0.0.0.0", port="8000")

5
lantern/route.py Normal file
View File

@ -0,0 +1,5 @@
from sanic.response import json
async def main_route(request, path=None):
return json({"hello": "world"})