Updated aiohttp & run_async examples, added redirect

This commit is contained in:
Shawn Niederriter 2017-04-06 19:42:05 +00:00
parent 46ac79f4dc
commit c30437448b
2 changed files with 18 additions and 1 deletions

View File

@ -3,7 +3,7 @@ from sanic import response
import aiohttp
app = Sanic()
app = Sanic(__name__)
async def fetch(session, url):
"""

View File

@ -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)