Spaces:
Build error
Build error
omerXfaruq
commited on
Commit
•
b219560
1
Parent(s):
311fc61
- add exception catch to the outside request
Browse files
app.py
CHANGED
@@ -132,14 +132,17 @@ class SpaceBuilder:
|
|
132 |
print(ex)
|
133 |
cls.error_message = "You have given an incorrect HuggingFace token"
|
134 |
return False
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
|
|
|
|
|
|
|
|
|
|
140 |
return False
|
141 |
-
else:
|
142 |
-
return True
|
143 |
|
144 |
@staticmethod
|
145 |
def build_space(space_names: str, hf_token: str, target_space_name: str, space_description: str) -> str:
|
|
|
132 |
print(ex)
|
133 |
cls.error_message = "You have given an incorrect HuggingFace token"
|
134 |
return False
|
135 |
+
try:
|
136 |
+
url = f"https://huggingface.co/spaces/{repo_name}"
|
137 |
+
response = requests.get(url)
|
138 |
+
if response.status_code == 200:
|
139 |
+
cls.error_message = "The the username/space_name is already used for the given token's user"
|
140 |
+
return False
|
141 |
+
else:
|
142 |
+
return True
|
143 |
+
except Exception as ex:
|
144 |
+
cls.error_message = "Can not send a request to https://huggingface.co"
|
145 |
return False
|
|
|
|
|
146 |
|
147 |
@staticmethod
|
148 |
def build_space(space_names: str, hf_token: str, target_space_name: str, space_description: str) -> str:
|