This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
2017-04-11 08:56:47 +01:00
|
|
|
from sanic import Sanic
|
2017-04-11 09:01:04 +01:00
|
|
|
from sanic.response import json, text
|
|
|
|
from sanic.exceptions import NotFound
|
2017-04-11 08:56:47 +01:00
|
|
|
|
|
|
|
app = Sanic()
|
|
|
|
|
|
|
|
@app.route("/")
|
|
|
|
async def test(request):
|
|
|
|
return json({"hello": "world"})
|
|
|
|
|
|
|
|
|
2017-04-11 09:01:04 +01:00
|
|
|
@app.exception(NotFound)
|
|
|
|
def ignore_404s(request, exception):
|
|
|
|
return text("Page not found at {}".format(request.url), status=404)
|
|
|
|
|
|
|
|
|
2017-04-11 08:56:47 +01:00
|
|
|
def main():
|
|
|
|
app.run(host="0.0.0.0", port="8000")
|