openfree commited on
Commit
49340e2
โ€ข
1 Parent(s): 6d77ca6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -17
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" # API ์ฟผ๋ฆฌ ์ˆ˜์ •
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 with automatic refresh
116
- with gr.Blocks() as app:
117
- html_output = gr.HTML()
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
- app.launch()
 
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()