diff --git a/index.html b/index.html
index b816bb6..a20d3e6 100644
--- a/index.html
+++ b/index.html
@@ -52,6 +52,7 @@
Sketchers United 4th Anniversary Collaboration
+ Currently we are featuring 150 images.
โค๏ธ๐งก๐๐๐๐
โ What is this?
@@ -103,8 +104,6 @@
-
-
diff --git a/script/annotations.js b/script/annotations.js
index 4a6217f..a51379a 100644
--- a/script/annotations.js
+++ b/script/annotations.js
@@ -20,27 +20,38 @@ function sendMessageToServer(message) {
anno.on('clickAnnotation', async function(annotation) {
let annotationValue = annotation.body[0].tag;
+ let newAnnotation = annotation;
+ newAnnotation.body[0].value = "๐ Downloading label...";
+ anno.updateSelected(newAnnotation);
+
+ let response = await sendMessageToServer(annotationValue);
+
+ let trueValueAnnotation = newAnnotation;
+
+ let site = "https://sketchersunited.org";
try {
- let newAnnotation = annotation;
- newAnnotation.body[0].value = "๐ Downloading label...";
- anno.updateSelected(newAnnotation);
-
- let response = await sendMessageToServer(annotationValue);
-
- let trueValueAnnotation = newAnnotation;
-
- let site = "https://sketchersunited.org"
- let post_id = response.post.id
- let post_name = response.post.title
- let poster_id = response.post.profile.id
- let poster_name = response.post.profile.username
- let poster_avatar = response.post.profile.profile_image_url_thumb
-
+ let post_id = response.post.id;
+ let post_name = response.post.title;
+ let poster_id = response.post.profile.id;
+ let poster_name = response.post.profile.username;
+ let poster_avatar = response.post.profile.profile_image_url_thumb;
trueValueAnnotation.body[0].value = ``;
-
anno.updateSelected(trueValueAnnotation);
- } catch (error) {
- console.error('Error:', error);
+ }
+ catch (error) {
+ try {
+ let poster_id = response.data.id;
+ let poster_name = response.data.username;
+ let poster_avatar = response.data.profile_image_url.replace("small", "thumb");
+ trueValueAnnotation.body[0].value = ``;
+ anno.updateSelected(trueValueAnnotation);
+ }
+ catch (error) {
+ console.log(`Post ${annotationValue} was dead: `, error);
+ newAnnotation.body[0].value = "โ An error occurred downloading the label.";
+ anno.updateSelected(newAnnotation);
+ }
}
+
});
diff --git a/script/image_load.js b/script/image_load.js
index 0d3f4ad..ae4d6f2 100644
--- a/script/image_load.js
+++ b/script/image_load.js
@@ -38,6 +38,7 @@ fetch('image/image.txt')
image_count++;
}
});
+ document.getElementById("current").innerText = `Currently we are featuring ${image_count} images.`;
})
.catch(error => {
console.error('Error:', error);
diff --git a/script/live.js b/script/live.js
index 7524607..beac032 100644
--- a/script/live.js
+++ b/script/live.js
@@ -1,5 +1,5 @@
const clientCountElement = document.getElementById('clientCount');
-const socket = new WebSocket('wss://sketchersunitedcollab.com/funsocket');
+const socket = new WebSocket('ws://localhost:8080/funsocket');
socket.addEventListener('message', (event) => {
if(event.data.toString().length < 5) {
diff --git a/websocket/websocket.py b/websocket/websocket.py
index f6afe5b..b1bc594 100644
--- a/websocket/websocket.py
+++ b/websocket/websocket.py
@@ -43,7 +43,22 @@ class WebSocketHandler(tornado.websocket.WebSocketHandler):
self.write_message(response.body)
except Exception as e:
- print(f"Error handling message: {e}")
+ if str(e) == "HTTP 404: Not Found":
+ try:
+ user_url = f"https://sketchersunited.org/users/{user}"
+
+ headers = {
+ "Accept": "application/json",
+ }
+ request = HTTPRequest(user_url, method="GET", headers=headers)
+
+ http_client = AsyncHTTPClient()
+ response = await http_client.fetch(request)
+ self.write_message(response.body)
+ except Exception as f:
+ print(f"Error getting user page: {f}")
+ else:
+ print(f"Error getting post page: {e}")
def on_message(self, message):
tornado.ioloop.IOLoop.current().add_callback(self.handle_message, message)