openfree commited on
Commit
a9e3b8d
ยท
verified ยท
1 Parent(s): e195ac6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -4
app.py CHANGED
@@ -5,7 +5,7 @@ import plotly.graph_objects as go
5
  from datetime import datetime
6
  import os
7
 
8
- HF_TOKEN = os.getenv('HF_TOKEN')
9
 
10
  # ๊ด€์‹ฌ ์ŠคํŽ˜์ด์Šค URL ๋ฆฌ์ŠคํŠธ์™€ ์ •๋ณด
11
  target_spaces = {
@@ -44,18 +44,28 @@ target_spaces = {
44
 
45
  def get_trending_spaces():
46
  try:
47
- url = "https://huggingface.co/api/spaces/sort/trending"
 
 
48
  headers = {
49
  'Authorization': f'Bearer {HF_TOKEN}',
50
  'Accept': 'application/json'
51
  }
52
- response = requests.get(url, headers=headers)
 
 
 
 
 
 
53
 
54
  if response.status_code == 200:
55
  return response.json()
56
  else:
57
  print(f"API ์š”์ฒญ ์‹คํŒจ: {response.status_code}")
58
  print(f"Response: {response.text}")
 
 
59
  return None
60
  except Exception as e:
61
  print(f"API ํ˜ธ์ถœ ์ค‘ ์—๋Ÿฌ ๋ฐœ์ƒ: {str(e)}")
@@ -235,4 +245,10 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
235
  df_output.value = initial_df
236
 
237
  # Gradio ์•ฑ ์‹คํ–‰
238
- demo.launch()
 
 
 
 
 
 
 
5
  from datetime import datetime
6
  import os
7
 
8
+ HF_TOKEN = os.getenv("HF_TOKEN")
9
 
10
  # ๊ด€์‹ฌ ์ŠคํŽ˜์ด์Šค URL ๋ฆฌ์ŠคํŠธ์™€ ์ •๋ณด
11
  target_spaces = {
 
44
 
45
  def get_trending_spaces():
46
  try:
47
+ # API ์—”๋“œํฌ์ธํŠธ ์ˆ˜์ •
48
+ url = "https://huggingface.co/api/spaces?sort=trending" # ์ˆ˜์ •๋œ URL
49
+
50
  headers = {
51
  'Authorization': f'Bearer {HF_TOKEN}',
52
  'Accept': 'application/json'
53
  }
54
+
55
+ params = {
56
+ 'limit': 1000, # ๋” ๋งŽ์€ ๊ฒฐ๊ณผ๋ฅผ ๊ฐ€์ ธ์˜ค๊ธฐ ์œ„ํ•ด limit ์ฆ๊ฐ€
57
+ 'full': 'true'
58
+ }
59
+
60
+ response = requests.get(url, headers=headers, params=params)
61
 
62
  if response.status_code == 200:
63
  return response.json()
64
  else:
65
  print(f"API ์š”์ฒญ ์‹คํŒจ: {response.status_code}")
66
  print(f"Response: {response.text}")
67
+ print(f"URL: {url}")
68
+ print(f"Headers: {headers}")
69
  return None
70
  except Exception as e:
71
  print(f"API ํ˜ธ์ถœ ์ค‘ ์—๋Ÿฌ ๋ฐœ์ƒ: {str(e)}")
 
245
  df_output.value = initial_df
246
 
247
  # Gradio ์•ฑ ์‹คํ–‰
248
+ if __name__ == "__main__":
249
+ demo.launch(
250
+ server_name="0.0.0.0",
251
+ server_port=7860,
252
+ share=False, # True๋กœ ์„ค์ •ํ•˜๋ฉด ๊ณต๊ฐœ ๋งํฌ ์ƒ์„ฑ
253
+ debug=True
254
+ )