openfree commited on
Commit
7fad5b1
·
verified ·
1 Parent(s): 059f849

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -17
app.py CHANGED
@@ -5,14 +5,7 @@ from datetime import datetime
5
 
6
  # Hugging Face Token
7
  HF_TOKEN = os.getenv("HF_TOKEN")
8
-
9
- def get_user_info():
10
- """Get username from token"""
11
- headers = {"Authorization": f"Bearer {HF_TOKEN}"}
12
- response = requests.get("https://huggingface.co/api/whoami", headers=headers)
13
- if response.status_code == 200:
14
- return response.json().get('name')
15
- return None
16
 
17
  def format_timestamp(timestamp):
18
  if timestamp:
@@ -26,9 +19,9 @@ def get_space_card(space):
26
  <div style='border: 1px solid #ddd; padding: 15px; margin: 10px; border-radius: 8px;
27
  background-color: white; box-shadow: 2px 2px 5px rgba(0,0,0,0.1);'>
28
  <h3 style='color: #2d2d2d; margin: 0 0 10px 0;'>
29
- <a href='https://huggingface.co/spaces/{space["id"]}' target='_blank'
30
  style='text-decoration: none; color: #2d2d2d;'>
31
- {space["id"].split("/")[-1]}
32
  </a>
33
  </h3>
34
  <p style='margin: 5px 0;'><strong>Space ID:</strong> {space["id"]}</p>
@@ -47,15 +40,11 @@ def get_user_spaces():
47
  if not HF_TOKEN:
48
  return "Error: Hugging Face token not found."
49
 
50
- username = get_user_info()
51
- if not username:
52
- return "Error: Could not get user information."
53
-
54
  headers = {"Authorization": f"Bearer {HF_TOKEN}"}
55
 
56
  # Get user's spaces
57
  response = requests.get(
58
- f"https://huggingface.co/api/spaces/{username}",
59
  headers=headers
60
  )
61
 
@@ -87,8 +76,8 @@ app = gr.Interface(
87
  fn=get_user_spaces,
88
  inputs=None,
89
  outputs=gr.HTML(),
90
- title="My Hugging Face Spaces Dashboard",
91
- description="Displays your Hugging Face Spaces in a grid layout",
92
  theme=gr.themes.Soft(),
93
  css="""
94
  .gradio-container {
 
5
 
6
  # Hugging Face Token
7
  HF_TOKEN = os.getenv("HF_TOKEN")
8
+ USERNAME = "openfree" # 특정 사용자 ID 설정
 
 
 
 
 
 
 
9
 
10
  def format_timestamp(timestamp):
11
  if timestamp:
 
19
  <div style='border: 1px solid #ddd; padding: 15px; margin: 10px; border-radius: 8px;
20
  background-color: white; box-shadow: 2px 2px 5px rgba(0,0,0,0.1);'>
21
  <h3 style='color: #2d2d2d; margin: 0 0 10px 0;'>
22
+ <a href='https://huggingface.co/spaces/{USERNAME}/{space["id"]}' target='_blank'
23
  style='text-decoration: none; color: #2d2d2d;'>
24
+ {space["id"]}
25
  </a>
26
  </h3>
27
  <p style='margin: 5px 0;'><strong>Space ID:</strong> {space["id"]}</p>
 
40
  if not HF_TOKEN:
41
  return "Error: Hugging Face token not found."
42
 
 
 
 
 
43
  headers = {"Authorization": f"Bearer {HF_TOKEN}"}
44
 
45
  # Get user's spaces
46
  response = requests.get(
47
+ f"https://huggingface.co/api/spaces/{USERNAME}",
48
  headers=headers
49
  )
50
 
 
76
  fn=get_user_spaces,
77
  inputs=None,
78
  outputs=gr.HTML(),
79
+ title=f"Hugging Face Spaces Dashboard - {USERNAME}",
80
+ description=f"Displays {USERNAME}'s Hugging Face Spaces in a grid layout",
81
  theme=gr.themes.Soft(),
82
  css="""
83
  .gradio-container {