Use httpie from windows git bash

Thing you want to do

As the title says, httpie was convenient, so I wondered if it could be used from windows git-bash.

Throw away curl and use httpie-Qiita http://qiita.com/yuku_t/items/5df06d50c4c349cc0c1b

procedure

First, install windows python (2.7 here) normally

Python Releases for Windows | Python.org https://www.python.org/downloads/windows/ Download Windows x86-64 MSI installer

Then pass the Path

pip and ipython installation guide (Windows) --secretbase.log http://cointoss.hatenablog.com/entry/20120531/1338474875

Reboot

Then, from git-bash

[12-14 18:22:36 ~]$ python --version
Python 2.7.13rc1
[12-14 18:22:37 ~]$ pip --version
pip 9.0.1 from c:\python27\lib\site-packages (python 2.7)
[12-14 18:22:41 ~]$ easy_install --version
setuptools 31.0.0 from c:\python27\lib\site-packages (Python 2.7)
[12-14 18:22:46 ~]$

Will be available.

Then install httpie

[12-14 18:17:08 ~]$ winpty pip install httpie
Collecting httpie
  Using cached httpie-0.9.9-py2.py3-none-any.whl
Requirement already satisfied: colorama>=0.2.4; sys_platform ==
"win32" in c:\python27\lib\site-packages (from httpie)
Requirement already satisfied: requests>=2.11.0 in
c:\python27\lib\site-packages (from httpie)
Requirement already satisfied: Pygments>=2.1.3 in
c:\python27\lib\site-packages (from httpie)
Installing collected packages: httpie
Successfully installed httpie-0.9.9
[12-14 18:19:24 ~]$

Run

[12-14 18:19:25 ~]$ winpty http https://www.google.co.jp/
HTTP/1.1 200 OK
Alt-Svc: quic=":443"; ma=2592000; v="35,34"
Cache-Control: private, max-age=0
Content-Encoding: gzip
Content-Type: text/html; charset=Shift_JIS
Date: Wed, 14 Dec 2016 09:19:30 GMT
...

Convenient!

... By the way, what is winpty! ??

What to do if Python doesn't work on Git for Windows-Qiita http://qiita.com/icoxfog417/items/33e6b1f3dd9358923e21

It seems that. Tweak the script or Let's do it quietly with winpty in mind.

http: error: Only terminal output can be colorized on Windows.

If you write the execution result of httpie to text from git-bash,

$ winpty http GET http://127.0.0.1/search/song word==ai count==5 --print hb --pretty format --output result.txt

If you want to do something like

usage: http [--json] [--form] [--pretty {all,colors,format,none}]
            [--style STYLE] [--print WHAT] [--headers] [--body] [--verbose]
            [--all] [--history-print WHAT] [--stream] [--output FILE]
            [--download] [--continue]
            [--session SESSION_NAME_OR_PATH | --session-read-only SESSION_NAME_OR_PATH]
            [--auth USER[:PASS]] [--auth-type {basic,digest}]
            [--proxy PROTOCOL:PROXY_URL] [--follow]
            [--max-redirects MAX_REDIRECTS] [--timeout SECONDS]
            [--check-status] [--verify VERIFY]
            [--ssl {ssl2.3,ssl3,tls1,tls1.1,tls1.2}] [--cert CERT]
            [--cert-key CERT_KEY] [--ignore-stdin] [--help] [--version]
            [--traceback] [--default-scheme DEFAULT_SCHEME] [--debug]
            [METHOD] URL [REQUEST_ITEM [REQUEST_ITEM ...]]
http: error: Only terminal output can be colorized on Windows.

It will be. To solve this problem, use cmd.exe instead of git-bash

C:\Users\XXXX> http GET http://127.0.0.1/search/song word==ai count==5 --print hb --pretty format --output result.txt

Then you can write the output in the formatted state. Note that you don't need winpty.

Recommended Posts

Use httpie from windows git bash
Launch the Python interpreter from Git bash
Python garbled in Windows + Git Bash environment
Run PIFuHD in Windows + Anaconda + Git Bash environment
[Bash] Use here-documents to get python power from bash
Use thingsspeak from python
Run Tensorflow from Jupyter Notebook on Bash on Ubuntu on Windows
Use fluentd from python
Use MySQL from Python
How to use python interactive mode with git bash
Use pyvenv on Windows
Use MySQL from Python
Use BigQuery from python.
Use Ansible on Windows
Use QuTiP on Windows
Use pip on Windows
Use mecab-ipadic-neologd from python
Use MySQL from Anaconda (python)
Use Windows 10 fonts with WSL
Use django model from interpreter
Use Python on Windows (PyCharm)
Use Linux on Windows 10 (WSL2)
Use e-Stat API from Python