title: Send HTTP request to localhost
body: <p>I'm building a Rest API with Flask. The API uses data from Elasticsearch that is running on localhost.</p>
  
  <p>It is possible to send an HTTP request from Flask route to localhost?</p>
  
  <p>Something like this:</p>
  
  <pre><code>@flashlog.route('/checkelasticisup')
  def check_elastic_is_up():
      res = requests.get('http://localhost:9200/')
      return jsonify({'message': res.text})
  </code></pre>
  
  <p>I want to return to the client the Elasticsearch response that you get when you send GET request to localhost:9200:</p>
  
  <pre><code>{
    "name": "wEV_Spx",
    "cluster_name": "elasticsearch",
    "cluster_uuid": "dbPLLgYLRO69iYuT_pp4WA",
    "version": {
      "number": "6.3.0",
      "build_flavor": "default",
      "build_type": "deb",
      "build_hash": "424e937",
      "build_date": "2018-06-11T23:38:03.357887Z",
      "build_snapshot": false,
      "lucene_version": "7.3.1",
      "minimum_wire_compatibility_version": "5.6.0",
      "minimum_index_compatibility_version": "5.0.0"
    },
    "tagline": "You Know, for Search"
  }
  </code></pre>
  
  <p>For now, I'm getting:</p>
  
  <blockquote>
    <p>Network Error (dns_unresolved_hostname)</p>
  </blockquote>
  
  <pre><code>&lt;HTML&gt;&lt;HEAD&gt;
  &lt;TITLE&gt;Network Error&lt;/TITLE&gt;
  &lt;/HEAD&gt;
  &lt;BODY&gt;
  &lt;FONT face="Helvetica"&gt;
  &lt;big&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/big&gt;&lt;BR&gt;
  &lt;/FONT&gt;
  &lt;blockquote&gt;
  &lt;TABLE border=0 cellPadding=1 width="80%"&gt;
  &lt;TR&gt;&lt;TD&gt;
  &lt;FONT face="Helvetica"&gt;
  &lt;big&gt;Network Error (dns_unresolved_hostname)&lt;/big&gt;
  &lt;BR&gt;
  &lt;BR&gt;
  &lt;/FONT&gt;
  &lt;/TD&gt;&lt;/TR&gt;
  &lt;TR&gt;&lt;TD&gt;
  &lt;FONT face="Helvetica"&gt;
  Your requested host "localhost" could not be resolved by DNS.
  &lt;/FONT&gt;
  &lt;/TD&gt;&lt;/TR&gt;
  &lt;TR&gt;&lt;TD&gt;
  &lt;FONT face="Helvetica"&gt;
  
  &lt;/FONT&gt;
  &lt;/TD&gt;&lt;/TR&gt;
  &lt;TR&gt;&lt;TD&gt;
  &lt;FONT face="Helvetica" SIZE=2&gt;
  &lt;BR&gt;
  For assistance, contact your network support team.
  &lt;/FONT&gt;
  &lt;/TD&gt;&lt;/TR&gt;
  &lt;/TABLE&gt;
  &lt;/blockquote&gt;
  &lt;/FONT&gt;
  &lt;/BODY&gt;&lt;/HTML&gt;
  </code></pre>
  
  <p>How can I send an HTTP request to localhost (I'm using Ubuntu 18.04 LTS)?<br>
  Thanks!!</p>