title: Creating a REST API for telnet connection
body: <p>I am working with a server that allows me to connect over telnet. I need to send it a few commands and return what they sent.</p>
  
  <pre><code>class LSController:
  def __init__(self, ssh_ip, ssh_user, ssh_pass, telnet_port):
      server = SSHTunnelForwarder(
      (ssh_ip, 22),
      ssh_username=ssh_user,
      ssh_password=ssh_pass,
      remote_bind_address=('127.0.0.1', telnet_port)
      )
  
      server.start()
      HOST = "localhost"
      tn = telnetlib.Telnet(HOST,server.local_bind_port)
      self.tn = tn        
  
      #get initial info
      tn.read_until('')
      tn.write('request.all\n')
      tn.read_until('END')
  
  def send_command(self, command):
      self.tn.write(command + '\n')
      return self.tn.read_until('END')
  </code></pre>
  
  <p>I'd like to create a simple REST API around it using Flask. What is the best way to approach this?</p>
  
  <p>For example one of the commands I want to have is:</p>
  
  <pre><code>    send_command('queue mytrack.mp3')
  </code></pre>