title: How to connect to localhost python flask API using Python
body: <p>I have local python flask based api running. It is running on below base url:</p>
  
  <pre><code>http://localhost:80/
  
   * Serving Flask app "main" (lazy loading)
   * Environment: production
     WARNING: Do not use the development server in a production environment.
     Use a production WSGI server instead.
   * Debug mode: off
   * Running on http://localhost:80/ (Press CTRL+C to quit)
  </code></pre>
  
  <p>Here is the code for it:</p>
  
  <pre><code>if __name__ == '__main__':
      import os
  
      HOST = os.environ.get('SERVER_HOST', 'localhost')
      try:
          PORT = int(os.environ.get('SERVER_PORT', '5555'))
      except ValueError:
          PORT = 5555
      app.run(HOST, 80)
  </code></pre>
  
  <p>I need to connect to the API for which the full URL is:</p>
  
  <pre><code>http://localhost:80/api/v1/face/recognize
  </code></pre>
  
  <p>I can connect to it using postman and getting good response. I have to connect to it using another python  project. For this I am using below code:</p>
  
  <pre><code>import http.client
  import json
  
  headers = {'appName': 'Tirunka', 'app_key': '6e0e36ff19de5623',
                             'Content-Type': 'application/json'}
  data = {
      "imageUrl": "kf7ZrqtJ5Sucu02eL7kerZrOG7Or ........ and so on ..........Haypep1uir/AKRH9K662T92K5TRh/",
      "galleryName": 'test'
  }
  
  json_data = json.dumps(data)
  
  conn = http.client.HTTPSConnection('http://localhost:80')
  conn.request("POST", "/api/v1/face/recognize", json_data, headers)
  </code></pre>
  
  <p>At this line <code>conn = http.client.HTTPSConnection('http://localhost:80/')</code>, I am getting below exception:</p>
  
  <pre><code>nonnumeric port: '80/'
  </code></pre>
  
  <p>I seem to have been using correct url. I am unable to understand the error. Can anyone please help. Thanks</p>