/
logout_button.py
61 lines (52 loc) 路 1.84 KB
/
logout_button.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""Predefined button to sign out from Hugging Face in a Gradio Space."""
from __future__ import annotations
import warnings
from typing import Literal
from gradio_client.documentation import document, set_documentation_group
from gradio.components import Button
set_documentation_group("component")
@document()
class LogoutButton(Button):
"""
Button to log out a user from a Space.
Note: `LogoutButton` component is deprecated. Please use `gr.LoginButton` instead
which handles both the login and logout processes.
"""
is_template = True
def __init__(
self,
value: str = "Logout",
*,
every: float | None = None,
variant: Literal["primary", "secondary", "stop"] = "secondary",
size: Literal["sm", "lg"] | None = None,
icon: str
| None = "https://huggingface.co/front/assets/huggingface_logo-noborder.svg",
# Link to logout page (which will delete the session cookie and redirect to landing page).
link: str | None = "/logout",
visible: bool = True,
interactive: bool = True,
elem_id: str | None = None,
elem_classes: list[str] | str | None = None,
render: bool = True,
scale: int | None = 0,
min_width: int | None = None,
):
warnings.warn(
"The `gr.LogoutButton` component is deprecated. Please use `gr.LoginButton` instead which handles both the login and logout processes."
)
super().__init__(
value,
every=every,
variant=variant,
size=size,
icon=icon,
link=link,
visible=visible,
interactive=interactive,
elem_id=elem_id,
elem_classes=elem_classes,
render=render,
scale=scale,
min_width=min_width,
)