Skip to content

Commit

Permalink
Update web.py
Browse files Browse the repository at this point in the history
add  remove_localstorage,refresh_page func
  • Loading branch information
HakunamatataLeo authored May 24, 2024
1 parent 4ed789f commit f4be763
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pywebio_battery/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from tornado.web import create_signed_value, decode_signed_value
from typing import *

__all__ = ['get_all_query', 'get_query', 'set_localstorage', 'get_localstorage', 'clear_localstorage', 'set_cookie', 'get_cookie',
__all__ = ['get_all_query', 'get_query', 'set_localstorage', 'get_localstorage', 'clear_localstorage', 'remove_localstorage', 'refresh_page', 'set_cookie', 'get_cookie',
'basic_auth', 'custom_auth', 'revoke_auth']


Expand Down Expand Up @@ -45,6 +45,16 @@ def clear_localstorage():
return eval_js("localStorage.clear()")


def remove_localstorage(key: str) -> str:
"""Remove the key from user's web browser local storage"""
return eval_js("localStorage.removeItem(key)", key=key)


def refresh_page():
"""Refresh the current page"""
return eval_js("location.reload()")


def _init_cookie_client():
session = get_current_session()
if 'cookie_client_flag' not in session.internal_save:
Expand Down

0 comments on commit f4be763

Please sign in to comment.