title: Python script doesn't send the output in my slack channel
body: <p>This is my nmap scanner wrote on python. It's scan ports and writes the results into json file (called result.json). I need to send the output of script into my slack chat (I made a bot in slack and set it up). I don't understand why script dont sends the output (when i try to send a simple text is working). I've tried a few variations(I add them into code) of post request in the script - resultless. So the question: how I can put the result of scanner into post request and sent it to slack chat?</p>
  <pre><code>import nmap
  import requests
  import json
  import os 
  os.remove(&quot;result.json&quot;)
  
  
  def my_scanner(host, port_range):
      scan_dict = {}
      nmScan = nmap.PortScanner()
      nmScan.scan(host, port_range)
      for host in nmScan.all_hosts():
          #scan_dict['ip'] = ip
          scan_dict['Host'] = host 
          #scan_dict['host_name'] =  nmScan[host].hostname()
          scan_dict['State'] = nmScan[host].state()
                  
          for proto in nmScan[host].all_protocols():
              scan_dict[proto] = {}
  
              lport = nmScan[host][proto].keys()
              sorted(lport)
              for port in lport:
                  scan_dict[proto][port] = nmScan[host][proto][port]['state']
          
      json_object = json.dumps(scan_dict)
  
      # Writing to sample.json
      with open(&quot;result.json&quot;, &quot;a&quot;) as outfile:
          outfile.write(json_object)
      return 
  
  ip_list = ['127.0.0.1','127.0.0.1']
  
  port_range_list = ['21-22']
  
  for host in ip_list:
      print(my_scanner(host,'21-22'))
  
  my_file = {
    'file' : ('/home/user/any_dir/result.json', open('/home/user/any_dir/result.json', 'rb'), 'json')
  }
  
  payload={
    &quot;filename&quot;:&quot;result.json&quot;, 
    &quot;token&quot;:&quot;https://hooks.slack.com/services/**************/**************/**************&quot;, 
    &quot;channels&quot;:['#1'],
  }
  
  r = requests.post(&quot;https://hooks.slack.com/services/******************/****************/****************&quot;, params=payload, files=my_file)
  
  #Second variation
  #data = {
  # 'file': ('/home/user/any_dir/result.json', open('/home/user/any_dir/result.json', 'rb'), 'json')
  # } 
  #requests.post('https://hooks.slack.com/services/*************/*****************/*****************', files=data)
  
  #Third variation which is work but only with text...
  #data = {'text': 'TARGET: #1'} 
  #requests.post('https://hooks.slack.com/services/*************/*****************/*****************', files=data)
  </code></pre>