class_docstr: HttpServer
  
  Flask HTTP server. Defines two routes, `/parameters` to GET current
  parameters held by this server, and `/update` which can be used to
  POST updates.
class_docstr_tok: ["HttpServer","Flask","HTTP","server",".","Defines","two","routes",",","`","\/parameters","`","to","GET","current","parameters","held","by","this","server",",","and","`","\/update","`","which","can","be","used","to","POST","updates","."]
docstr: Define Flask parameter server service.
  
  This HTTP server can do two things: get the current model
  parameters and update model parameters. After registering
  the `parameters` and `update` routes, the service will
  get started.
docstr_tok: ["Define","Flask","parameter","server","service",".","This","HTTP","server","can","do","two","things",":","get","the","current","model","parameters","and","update","model","parameters",".","After","registering","the","`","parameters","`","and","`","update","`","routes",",","the","service","will","get","started","."]
code: def start_flask_service(self):
      """Define Flask parameter server service.
  
      This HTTP server can do two things: get the current model
      parameters and update model parameters. After registering
      the `parameters` and `update` routes, the service will
      get started.
  
      """
      app = Flask(__name__)
      self.app = app
  
      @app.route("/")
      def home():
          return "Elephas"
  
      @app.route("/parameters", methods=["GET"])
      def handle_get_parameters():
          if self.mode == "asynchronous":
              self.lock.acquire_read()
          self.pickled_weights = pickle.dumps(self.weights, -1)
          pickled_weights = self.pickled_weights
          if self.mode == "asynchronous":
              self.lock.release()
          return pickled_weights
  
      @app.route("/update", methods=["POST"])
      def handle_update_parameters():
          delta = pickle.loads(request.data)
          if self.mode == "asynchronous":
              self.lock.acquire_write()
  
          if not self.master_network.built:
              self.master_network.build()
  
          # Just apply the gradient
          weights_before = self.weights
          self.weights = subtract_params(weights_before, delta)
  
          if self.mode == "asynchronous":
              self.lock.release()
          return "Update done"
  
      master_url = determine_master(self.port)
      host = master_url.split(":")[0]
      self.app.run(
          host=host,
          debug=self.debug,
          port=self.port,
          threaded=self.threaded,
          use_reloader=self.use_reloader,
      )
  
imports: import abc
  import pickle
  import socket
  from threading import Thread
  from flask import Flask, request
  from multiprocessing import Process
  from tensorflow.keras.models import Model
  from elephas.utils.sockets import determine_master
  from elephas.utils.sockets import receive, send
  from elephas.utils.serialization import dict_to_model
  from elephas.utils.rwlock import RWLock
  from elephas.utils.notebook_utils import is_running_in_notebook
  from elephas.utils import subtract_params
label_desc: Use image node_id 4 for calling the HttpServer obj's underlying member method code with example usage: obj.start_flask_service() and returns: str, pickled_weights, str