Last active
April 26, 2020 20:25
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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