Updated aiohttp & run_async examples, added redirect
This commit is contained in:
parent
46ac79f4dc
commit
c30437448b
@ -3,7 +3,7 @@ from sanic import response
|
|||||||
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
|
||||||
app = Sanic()
|
app = Sanic(__name__)
|
||||||
|
|
||||||
async def fetch(session, url):
|
async def fetch(session, url):
|
||||||
"""
|
"""
|
||||||
|
17
examples/redirect_example.py
Normal file
17
examples/redirect_example.py
Normal 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)
|
Loading…
x
Reference in New Issue
Block a user