在用aiohttp编写server的时候,在用户登录这块需要跳转到单点登录页面,而这个链接是外部程序怎么办?下面记录下跳转程序:
站内跳转:
def redirect(router, route_name): location = router[route_name].url_for() return web.HTTPFound(location) redirect(request.app.router, 'index')
站外跳转(跳转百度)
from aiohttp import web
return web.Response(
headers={
'Location': 'http://www.baidu.com'
},
status=303
)