Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,9 @@
|
|
1 |
import requests
|
|
|
2 |
from typing import List, Dict, Union
|
3 |
|
|
|
|
|
4 |
def get_most_liked_spaces(limit: int = 100) -> Union[List[Dict], str]:
|
5 |
url = "https://huggingface.co/api/spaces"
|
6 |
params = {
|
@@ -48,12 +51,31 @@ def format_spaces(spaces: Union[List[Dict], str]) -> List[str]:
|
|
48 |
|
49 |
return formatted_spaces
|
50 |
|
51 |
-
|
52 |
-
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
if __name__ == "__main__":
|
56 |
-
|
57 |
-
result = get_spaces_list()
|
58 |
-
for idx, space in enumerate(result, 1):
|
59 |
-
print(f"{idx}. {space}")
|
|
|
1 |
import requests
|
2 |
+
from flask import Flask, render_template_string
|
3 |
from typing import List, Dict, Union
|
4 |
|
5 |
+
app = Flask(__name__)
|
6 |
+
|
7 |
def get_most_liked_spaces(limit: int = 100) -> Union[List[Dict], str]:
|
8 |
url = "https://huggingface.co/api/spaces"
|
9 |
params = {
|
|
|
51 |
|
52 |
return formatted_spaces
|
53 |
|
54 |
+
@app.route('/')
|
55 |
+
def index():
|
56 |
+
spaces_list = get_most_liked_spaces()
|
57 |
+
formatted_spaces = format_spaces(spaces_list)
|
58 |
+
|
59 |
+
html_template = """
|
60 |
+
<!DOCTYPE html>
|
61 |
+
<html lang="en">
|
62 |
+
<head>
|
63 |
+
<meta charset="UTF-8">
|
64 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
65 |
+
<title>Hugging Face Most Liked Spaces</title>
|
66 |
+
</head>
|
67 |
+
<body>
|
68 |
+
<h1>Hugging Face Most Liked Spaces</h1>
|
69 |
+
<ol>
|
70 |
+
{% for space in spaces %}
|
71 |
+
<li>{{ space }}</li>
|
72 |
+
{% endfor %}
|
73 |
+
</ol>
|
74 |
+
</body>
|
75 |
+
</html>
|
76 |
+
"""
|
77 |
+
|
78 |
+
return render_template_string(html_template, spaces=formatted_spaces)
|
79 |
|
80 |
if __name__ == "__main__":
|
81 |
+
app.run(host='0.0.0.0', port=7860)
|
|
|
|
|
|