old_contents: #!/usr/bin/env python3
  # -*- coding: utf-8 -*-
  
  from socket import *
  from car import Car
  
  Car.init()
  
  commands = {
      'forward': Car.forward,
      'back': Car.back,
      'left': Car.turn_left,
      'right': Car.turn_right,
      'stop': Car.stop()
  }
  
  
  def execute(command):
      print(command)
      commands[command]()
  
  HOST = '0.0.0.0'
  PORT = 9876
  
  sock = socket(AF_INET, SOCK_STREAM)
  sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
  sock.bind((HOST, PORT))
  sock.listen(1)
  print('listening on %s:%d' % (HOST, PORT))
  
  try:
      while True:
          conn, addr = sock.accept()
          print('Connected by:', addr)
          try:
              while True:
                  data = conn.recv(1024)
                  if not data.strip():
                      print('recv is null')
                      break
                  command = data.decode('utf-8').replace('\n', '')
                  if not command:
                      break
                  execute(command)
                  conn.send('Done!'.encode('utf-8'))
  
          except Exception as e:
              print('---- Exception: ', e)
              sock.shutdown(SHUT_RDWR)
              conn.close()
              sock.close()
              print('socket closed!')
  
  except KeyboardInterrupt:
      Car.cleanup()
      sock.shutdown(SHUT_RDWR)
      sock.close()
  
new_contents: #!/usr/bin/env python3
  # -*- coding: utf-8 -*-
  
  from socket import *
  from car import Car
  
  Car.init()
  
  commands = {
      'forward': Car.forward,
      'back': Car.back,
      'left': Car.turn_left,
      'right': Car.turn_right,
      'stop': lambda: 1 + 2
  }
  
  
  def execute(command):
      print(command)
      commands[command]()
  
  HOST = '0.0.0.0'
  PORT = 9876
  
  sock = socket(AF_INET, SOCK_STREAM)
  sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
  sock.bind((HOST, PORT))
  sock.listen(1)
  print('listening on %s:%d' % (HOST, PORT))
  
  try:
      while True:
          conn, addr = sock.accept()
          print('Connected by:', addr)
          try:
              while True:
                  data = conn.recv(1024)
                  if not data.strip():
                      print('recv is null')
                      break
                  command = data.decode('utf-8').replace('\n', '')
                  if not command:
                      break
                  execute(command)
                  conn.send('Done!'.encode('utf-8'))
  
          except Exception as e:
              print('---- Exception: ', e)
              sock.shutdown(SHUT_RDWR)
              conn.close()
              sock.close()
              print('socket closed!')
  
  except KeyboardInterrupt:
      Car.cleanup()
      sock.shutdown(SHUT_RDWR)
      sock.close()
  
subject: add stop command to raspservice.py