File size: 1,322 Bytes
13dbd3b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# from huggingface_hub import HfApi

# my_token = """  
# api = HfApi(token=my_token)

# spaces = api.list_spaces(author="uav-vts")  # hoặc namespace bạn được cấp
# for space in spaces:
#     print(space.id, getattr(space, "private", "N/A"), getattr(space, "sdk", "N/A"))


from huggingface_hub import HfApi

my_token = ""  

my_namespace = "uav-vts"  

api = HfApi(token=my_token)

spaces = api.list_spaces(author=my_namespace)

if not spaces:
    print("Không tìm thấy Space nào trong namespace / resource group này.")
else:
    print(f"Tìm thấy {len(list(spaces))} Space(s) trong namespace '{my_namespace}':\n")
    for space in spaces:
        owner, name = space.id.split("/") if "/" in space.id else ("unknown", space.id)
        url = f"https://huggingface.co/spaces/{space.id}"
        private = getattr(space, "private", "N/A")
        sdk = getattr(space, "sdk", "N/A")
        last_modified = getattr(space, "lastModified", "N/A")
        # Trạng thái có thể lấy từ cardData nếu expand=["cardData"]
        status = getattr(getattr(space, "cardData", {}), "status", "N/A")
        
        print(f"Owner: {owner}, Name: {name}")
        print(f"URL: {url}")
        print(f"Private: {private}, SDK: {sdk}, LastModified: {last_modified}, Status: {status}")
        print("-" * 60)