官术网_书友最值得收藏!

  • Django RESTful Web Services
  • Gaston C. Hillar
  • 307字
  • 2021-06-30 19:30:56

Installing HTTPie

Now, we will install HTTPie, a command-line HTTP client written in Python that makes it easy to send HTTP requests and uses a syntax that is easier than curl. By default, HTTPie displays colorized output and uses multiple lines to display the response details. In some cases, HTTPie makes it easier to understand the responses than the curl utility. However, one of the great disadvantages of HTTPie as a command-line utility is that it takes more time to load than curl, and therefore, if you want to code scripts with too many commands, you have to evaluate whether it makes sense to use HTTPie.

We just need to make sure we run the following command in the virtual environment we have just created and activated. This way, we will install HTTPie only for our virtual environment.

Run the following command in the terminal, Command Prompt, or Windows PowerShell to install the httpie package:

pip install --upgrade httpie

The last lines of the output will indicate that the httpie package has been successfully installed:

    Collecting httpie
    Collecting colorama>=0.2.4 (from httpie)
    Collecting requests>=2.11.0 (from httpie)
    Collecting Pygments>=2.1.3 (from httpie)
    Collecting idna<2.7,>=2.5 (from requests>=2.11.0->httpie)
    Collecting urllib3<1.23,>=1.21.1 (from requests>=2.11.0->httpie)
    Collecting chardet<3.1.0,>=3.0.2 (from requests>=2.11.0->httpie)
    Collecting certifi>=2017.4.17 (from requests>=2.11.0->httpie)
    Installing collected packages: colorama, idna, urllib3, chardet, certifi, requests, Pygments, httpie
    Successfully installed Pygments-2.2.0 certifi-2017.7.27.1 chardet-3.0.4 colorama-0.3.9 httpie-0.9.9 idna-2.6 requests-2.18.4 urllib3-1.22
  
If you don't remember how to activate the virtual environment that we created for this example, read the  Activating the virtual environment section in this chapter.

Now, we will be able to use the http command to easily compose and send HTTP requests to our future RESTful Web Services build with Django. The following screenshot shows the results of executing http on Command Prompt in Windows 10. HTTPie displays the valid options and indicates that a URL is required:

主站蜘蛛池模板: 电白县| 常德市| 永吉县| 沿河| 锦州市| 湟源县| 高密市| 汶上县| 化隆| 扶风县| 文昌市| 大英县| 黔西| 德惠市| 石泉县| 大余县| 承德县| 遂平县| 曲阳县| 奉贤区| 四子王旗| 蓬莱市| 新竹县| 慈利县| 周至县| 娄烦县| 清水河县| 安达市| 台中市| 通州市| 黔南| 湛江市| 万安县| 彰化市| 鱼台县| 北川| 龙游县| 隆子县| 德州市| 于田县| 玉山县|