class UploadHandler (tornado.web.RequestHandler): def post(self): fileinfo = self.request.files['print-file'][0] with open('uploads/PrintFile.svg', 'w') as printFile: printFile.write(fileinfo['body']) with open('uploads/PrintFile.svg', 'r') as printFile: LAVAPrinter.SetPrintFile(printFile) SetEstimatedPrintFinishedDate(LAVAPrinter.GetEstimatedPrintSeconds()) application = tornado.web.Application([ (r'/', MainHandler), (r'/websocket', WebSocketHandler), (r'/upload', UploadHandler) ], template_path=os.path.join(os.path.dirname(__file__), "templates"), static_path=os.path.join(os.path.dirname(__file__), "static"), debug=True) if __name__ == "__main__": LAVAPrinter = Printer(STEPPER_DIRECTION_PIN, STEPPER_STEP_PIN, PROJECTOR_RESOLUTION, AP_PASSWORD, RESIN_CURE_TIME, LAYER_HEIGHT, THREADS_PER_INCH) LAVAPrinter.DisplayAPPassword() http_server = tornado.httpserver.HTTPServer(application) http_server.listen(8888) tornado.ioloop.IOLoop.instance().start()