Skip to content

Instantly share code, notes, and snippets.

@burrussmp
Last active April 26, 2020 20:25
Show Gist options
  • Save burrussmp/60b750c3d108ad80bad387e0deec518b to your computer and use it in GitHub Desktop.
Save burrussmp/60b750c3d108ad80bad387e0deec518b to your computer and use it in GitHub Desktop.
A GET handler to stringify a list of faces where each element in the list is a set of points that define the face in a clockwise winding order
def get_mesh(self):
if processor.ready_to_send():
faces = processor.get_faces()
"""Respond to a GET request."""
self.send_response(200)
self.send_header("Content-type", "text")
self.end_headers()
for i in range(len(faces)):
self.wfile.write("N".encode())
self.wfile.write(str(len(faces[i])).encode())
self.wfile.write(",".encode())
for j in range(len(faces[i])):
self.wfile.write(json.dumps(faces[i][j]).encode())
if j != len(faces[i])-1:
self.wfile.write(",".encode())
else:
self.send_response(500)
self.send_header("Content-type", "text")
self.end_headers()
self.wfile.write("Error: Do not have enough pictures to construct 3D object.".encode())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment