Skip to content

Commit

Permalink
Update web.py
Browse files Browse the repository at this point in the history
add remove_localstorage, refresh_page
  • Loading branch information
HakunamatataLeo authored May 24, 2024
1 parent 4ed789f commit a41ce9a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 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 @@ -44,6 +44,13 @@ def clear_localstorage():
"""Clear user's web browser local storage"""
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()
Expand Down

0 comments on commit a41ce9a

Please sign in to comment.