Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async def logout(request):
auth.logout_user(request)
return response.redirect('/user')
async def add_session_to_request(request):
# before each request initialize a session
# using the client's request
host = request.headers.get('host', None)
user_agent = request.headers.get('user-agent', None)
if user_agent:
user_ip = request.headers.get('X-Forwarded-For')
LOGGER.info('user ip is: {}'.format(user_ip))
if user_ip in CONFIG.FORBIDDEN:
return html("<h3>网站正在维护...</h3>")
if CONFIG.VAL_HOST == 'true':
if not host or host not in CONFIG.HOST:
return redirect('http://www.owllook.net')
if CONFIG.WEBSITE['IS_RUNNING']:
await app.session_interface.open(request)
else:
return html("<h3>网站正在维护...</h3>")
else:
return html("<h3>网站正在维护...</h3>")
async def download(req, feed_id, video_id):
if req.method == 'HEAD':
return response.text('')
try:
redirect_url = resolver.download(feed_id, video_id)
return response.redirect(redirect_url)
except resolver.InvalidUsage:
raise InvalidUsage()
except resolver.QuotaExceeded:
raise ServerError('Too many requests. Daily limit is 1000. Consider upgrading account to get unlimited access.',
status_code=429)
async def test_redirect(request):
return response.redirect(app.url_for('index'))
async def logout(request, user):
resp = response.redirect("/login")
del resp.cookies['access_token']
del resp.cookies['refresh_token']
# now actually invalidate tokens
await invalidate_refresh_token(user['id'])
return resp
def authorize(request):
if aiogoogle.oauth2.is_ready(CLIENT_CREDS):
uri = aiogoogle.oauth2.authorization_url(
client_creds=CLIENT_CREDS,
state=state,
access_type="offline",
include_granted_scopes=True,
login_hint=EMAIL,
prompt="select_account",
)
# Step A
return response.redirect(uri)
else:
raise ServerError("Client doesn't have enough info for Oauth2")
async def index(request):
# generate a URL for the endpoint `post_handler`
url = app.url_for('post_handler', post_id=5)
# the URL is `/posts/5`, redirect to it
return response.redirect(url)
'都市',
'职场',
'军事',
'历史',
'游戏',
'体育',
'科幻',
'灵异',
'二次元',
]
if novels_type in first_type:
novels_head = [novels_type]
elif novels_type == first_type_title:
novels_head = ['#']
else:
return redirect('qidian')
search_ranking = await cache_others_search_ranking(spider='qidian', novel_type=novels_type)
title = "owllook - 起点小说榜单"
if user:
return template('index.html',
title=title,
is_login=1,
is_qidian=1,
is_qidian_model=1,
user=user,
search_ranking=search_ranking,
first_type=first_type,
first_type_title=first_type_title,
novels_head=novels_head)
else:
return template('index.html',
title=title,
def redirect_to_index(request: request.Request) -> response.HTTPResponse:
return response.redirect(
request.app.url_for(handler_name(client_files), path="index.html")
)
async def check_request(request):
if CONFIG.VAL_HOST == '1':
host = request.headers.get('host', None)
if not host or host not in CONFIG.HOST:
return redirect('http://www.baidu.com')