def do_GET(self): ''' Respond to a "GET" request. ''' try: autodesk.write_line('GET request: ' + self.path) # Send headers, but abort if not successful. if not self.send_headers(): return # Shut down the web server if '/exit' == self.path: Handler.shutting_down = True self.wfile.write('shutting down web server') # Return a JSON representation of the scene (without meshes) in the response. elif '/scene' == self.path: self.wfile.write(autodesk.scene_json()) # Return the product name in the response. elif '/test' == self.path: self.wfile.write("This is a test. You are running " + autodesk.app.product) # Return a tree representation of the scene in the response. elif '/tree' == self.path: autodesk.output_scene_tree(self.wfile) # Return a JSON representation of the mesh of the first selected object. elif '/mesh' == self.path: self.wfile.write(autodesk.selected_mesh_json()) # Echo the query request. else: self.wfile.write(self.path) except: self.wfile.write('Error occured') Handler.shutting_down = True
def do_GET(self): try: if Handler.shutting_down: self.send_response(503) return self.send_response(200) self.send_header("Content-type", "text/plain") self.send_header("Accept", "text/plain") self.end_headers() if '/exit' == self.path: Handler.shutting_down = True self.wfile.write('shutting down web server') elif '/scene' == self.path: self.wfile.write(autodesk.scene_json()) elif '/test' == self.path: self.wfile.write("This is a test") elif '/tree' == self.path: autodesk.output_scene_tree(self.wfile) elif '/mesh' == self.path: self.wfile.write(autodesk.selected_mesh_json()) else: self.wfile.write(self.path) except: Handler.shutting_down = True
import autodesk app = autodesk.common.app app.write_line(autodesk.scene_json()) if autodesk.selected(): app.write_line(autodesk.selected_mesh_json())