diff --git a/examples/aiohttp_example.py b/examples/aiohttp_example.py index 0762f5d4..f8043d5c 100644 --- a/examples/aiohttp_example.py +++ b/examples/aiohttp_example.py @@ -3,7 +3,7 @@ from sanic import response import aiohttp -app = Sanic() +app = Sanic(__name__) async def fetch(session, url): """ diff --git a/examples/redirect_example.py b/examples/redirect_example.py new file mode 100644 index 00000000..c062a76f --- /dev/null +++ b/examples/redirect_example.py @@ -0,0 +1,17 @@ +from sanic import Sanic +from sanic import response + +app = Sanic(__name__) + + +@app.route('/') +def handle_request(request): + return response.redirect('/redirect') + +@app.route('/redirect') +async def test(request): + return response.json({"Redirected": True}) + + +if __name__ == '__main__': + app.run(host="0.0.0.0", port=8080) \ No newline at end of file