Search code examples
pythonhttpie

how to run httpie from script.py


I need to send forms to a rest service from py-scripts. i try to do it using httpie.

when i invoke run(['http', '--help']) i've got expected result. if i invoke run(['http', 'http://site/page']) the script is stuck and nothig happens.

I also tried to place running of httpie into bash script

#!/bin/bash
http http://site/page

the result is the same as in the first case. script is stuck.

I use ubuntu 16.04 so I have python2 and python3 at the same time. I run my script by python3. mayby is there a conflict between p2 & p3 in ths case?


Solution

  • Try to include the --ignore-stdin option:

    run(['http', '--ignore-stdin', 'http://site/page'])
    

    The --ignore-stdin option prevents HTTPie from reading data from stdin, which is usually not desirable during non-interactive invocations.

    https://github.com/jkbrzt/httpie#scripting