title: Execute curl command within a Python script
body: <p>I am trying to execute a curl command within a python script.</p>
  
  <p>If I do it in the terminal, it looks like this:</p>
  
  <pre><code>curl -X POST -d  '{"nw_src": "10.0.0.1/32", "nw_dst": "10.0.0.2/32", "nw_proto": "ICMP", "actions": "ALLOW", "priority": "10"}' http://localhost:8080/firewall/rules/0000000000000001
  </code></pre>
  
  <p>I've seen recommendations to use <code>pycurl</code>, but I couldn't figure out how to apply it to mine.</p>
  
  <p>I tried using:</p>
  
  <pre><code>subprocess.call([
      'curl',
      '-X',
      'POST',
      '-d',
      flow_x,
      'http://localhost:8080/firewall/rules/0000000000000001'
  ])
  </code></pre>
  
  <p>and it works, but is there a better way?</p>