Update app.py
Browse files
app.py
CHANGED
@@ -52,7 +52,7 @@ def get_space_card(space):
|
|
52 |
"""
|
53 |
|
54 |
def get_user_spaces():
|
55 |
-
url = f"https://huggingface.co/api/spaces?author={USERNAME}&limit=500"
|
56 |
headers = {
|
57 |
"Accept": "application/json",
|
58 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
|
@@ -67,8 +67,6 @@ def get_user_spaces():
|
|
67 |
return f"Error: Failed to fetch spaces (Status Code: {response.status_code})"
|
68 |
|
69 |
spaces_data = response.json()
|
70 |
-
|
71 |
-
# Filter spaces for the specific user (although API should already filter)
|
72 |
user_spaces = spaces_data
|
73 |
|
74 |
if not user_spaces:
|
@@ -80,10 +78,8 @@ def get_user_spaces():
|
|
80 |
</div>
|
81 |
"""
|
82 |
|
83 |
-
# Sort spaces by likes (most liked first)
|
84 |
user_spaces.sort(key=lambda x: x.get('likes', 0), reverse=True)
|
85 |
|
86 |
-
# Create HTML grid layout
|
87 |
html_content = f"""
|
88 |
<div style='padding: 20px; background-color: #f5f5f5;'>
|
89 |
<div style='margin-bottom: 20px;'>
|
@@ -112,17 +108,11 @@ def get_user_spaces():
|
|
112 |
</div>
|
113 |
"""
|
114 |
|
115 |
-
# Creating the Gradio interface
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
#
|
120 |
-
gr.on(
|
121 |
-
triggers=[], # ๋น triggers๋ ํ์ด์ง ๋ก๋ ์ ์คํ์ ์๋ฏธ
|
122 |
-
fn=get_user_spaces,
|
123 |
-
outputs=[html_output],
|
124 |
-
)
|
125 |
|
126 |
-
# Launch the Gradio app
|
127 |
if __name__ == "__main__":
|
128 |
-
|
|
|
52 |
"""
|
53 |
|
54 |
def get_user_spaces():
|
55 |
+
url = f"https://huggingface.co/api/spaces?author={USERNAME}&limit=500"
|
56 |
headers = {
|
57 |
"Accept": "application/json",
|
58 |
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
|
|
|
67 |
return f"Error: Failed to fetch spaces (Status Code: {response.status_code})"
|
68 |
|
69 |
spaces_data = response.json()
|
|
|
|
|
70 |
user_spaces = spaces_data
|
71 |
|
72 |
if not user_spaces:
|
|
|
78 |
</div>
|
79 |
"""
|
80 |
|
|
|
81 |
user_spaces.sort(key=lambda x: x.get('likes', 0), reverse=True)
|
82 |
|
|
|
83 |
html_content = f"""
|
84 |
<div style='padding: 20px; background-color: #f5f5f5;'>
|
85 |
<div style='margin-bottom: 20px;'>
|
|
|
108 |
</div>
|
109 |
"""
|
110 |
|
111 |
+
# Creating the Gradio interface
|
112 |
+
demo = gr.Blocks()
|
113 |
+
|
114 |
+
with demo:
|
115 |
+
html_output = gr.HTML(value=get_user_spaces()) # ์ด๊ธฐ ๋ก๋ ์ ์ง์ ํจ์ ํธ์ถ
|
|
|
|
|
|
|
|
|
|
|
116 |
|
|
|
117 |
if __name__ == "__main__":
|
118 |
+
demo.launch()
|