Testing Web Services with Httpie

Source: Internet
Author: User
Tags auth virtual environment

Flask Web Development P168 1. The question

(venv) C:\Users\Geek lee\flasky>http--json--auth 123456789@qq.com:password get \

http:error:ConnectionError: Httpconnectionpool (host= '%5c ', port=80): Max retries exceeded with URL:/(Caused by <class ' socket.gaierror ': [ERR No 11004] getaddrinfo failed)
2. Address1. Open the virtual environment in the first command-line window, start the Web server the last two lines have obtained the Web service message
C:\Users\Geek lee\flasky>venv\scripts\activate
(venv) C:\Users\Geek Lee\flasky>python manage.py runserver
 * Running on http://127.0.0.1:5000/(press CTRL + C to quit)
 * Restarting with stat 127.0.0.1
--[05/sep/2016 20:52:11] "get/http/1.1"-
127.0.0.1--[05/sep/2016 20:53:09] "get/http/1.1"-127.0.0.1--
[05/sep /2016 20:54:34] "get/api/v1.0/posts http/1.1"-
127.0.0.1--[05/sep/2016 20:55:38] "GET/API/V1.0/POSTS/HTTP/1 .1 "127.0.0.1--
[05/sep/2016 20:56:05]" get/api/v1.0/posts/http/1.1 "200-
2. In another open command line, enter the full url,email and password for the real email address and password, both sides of the <><> removed.
Input (note: End of line input)
(venv) $:>http--json--auth 123456789@qq.com:password get http://127.0.0.1:5000/api/v1.0/posts/

Results

(venv) $:>http--json--auth 123456789@qq.com:password get http://127.0.0.1:5000/api/v1.0/posts/HTTP/1.0 OK content-length:8456 Content-type:application/json Date:mon, Sep 2016 12:56:05 GMT server:werkzeug/0.10.4 Python/3.4 .3 {"Count": +, "Next": "http://127.0.0.1:5000/api/v1.0/posts/?page=2", "posts": [{] Author ":" Http://127.0.0.1:5000/api/v1.0/users/4 "," Body ":" SSS "," body_html ": null," Comment_count ": 0," comments ":" http://127.0.0.1:5000/api/v1.0/posts/1/comments/"," timestamp ":" F
            RI, SEP 2016 02:32:52 GMT ", url": "Http://127.0.0.1:5000/api/v1.0/posts/1"}, {
            "Author": "Http://127.0.0.1:5000/api/v1.0/users/4", "Body": "Fsdfsdfs", "body_html": null, "Comment_count": 0, "comments": "http://127.0.0.1:5000/api/v1.0/posts/2/comments/", "Times Tamp ":" Fri, SEP 2016 02:32: GMT ", url": "Http://127.0.0.1:5000/api/v1.0/posts/2"}, {"Author": "Http://1 27.0.0.1:5000/API/V1.0/USERS/4 "," Body ":" Sdfsdfsfs "," body_html ": null," Comment_coun T ": 0," comments ":" http://127.0.0.1:5000/api/v1.0/posts/3/comments/"," timestamp ":" Fri, SEP 2 016 02:32:59 GMT ", url": "Http://127.0.0.1:5000/api/v1.0/posts/3"}, {"Author": "HTTP://127.0.0.1:5000/API/V1.0/USERS/4", "Body": "FSDFSFSAFSFA", "body_html": null, " Comment_count ": 0," comments ":" http://127.0.0.1:5000/api/v1.0/posts/4/comments/"," timestamp ":" F
            RI, SEP 2016 02:33:03 GMT ", url": "Http://127.0.0.1:5000/api/v1.0/posts/4"}, { "Author": "Http://127.0.0.1:5000/api/v1.0/users/4", "body": "Why."
 "," body_html ": null," Comment_count ": 0,           "Comments": "http://127.0.0.1:5000/api/v1.0/posts/5/comments/", "timestamp": "Fri, SEP 2016 02:5 1:08 GMT ", url": "HTTP://127.0.0.1:5000/API/V1.0/POSTS/5"}, {"Author": "http:// 127.0.0.1:5000/api/v1.0/users/7 "," Body ":" Etiam vel augue. "," body_html ": null," comm Ent_count ": 0," comments ":" http://127.0.0.1:5000/api/v1.0/posts/6/comments/"," timestamp ":" Wed, Aug 2016 00:00:00 GMT ", url": "HTTP://127.0.0.1:5000/API/V1.0/POSTS/6"}, {"A Uthor ":" HTTP://127.0.0.1:5000/API/V1.0/USERS/39 "," Body ":" CRAs in Purus EU magna vulputate. Suspendisse potent i. In Quis Justo. Morbi vestibulum, velit ID pretium iaculis, diam erat fermentu m justo, nec condimentum neque sapien, Placerat. Etiam vel augue. "," body_html ": null," Comment_count ": 0," comments ":" http://127.0.0. " 1:5000/api/v1.0/posts/7/comments/"," timestamp ":" Fri, Aug 2016 00:00:00 GMT "," url ":" http://127
            .0.0.1:5000/api/v1.0/posts/7 "}, {" Author ":" HTTP://127.0.0.1:5000/API/V1.0/USERS/52 ", "Body": "Integer ac neque." Vestibulum rutrum rutrum Neque.
            Aenean au ctor gravida sem. Quisque ut erat. "," body_html ": null," Comment_count ": 0,
            "Comments": "http://127.0.0.1:5000/api/v1.0/posts/8/comments/", "timestamp": "Mon, Aug 2016 00:00:00 GMT", "url": "Http://127.0.0.1:5000/api/v1.0/posts/8"}, {"Author": "Http://127.0.0.1:5
            000/API/V1.0/USERS/3 "," Body ":" Donec posuere metus vitae ipsum. "," body_html ": null, "Comment_count": 0, "comments": "http://127.0.0.1:5000/api/v1.0/posts/9/comments/", "timestamp": " Sat, Aug 2016 00:00:00 GMT "," url ":" Http://127.0.0.1:5000/api/v1.0/posts/9 "}, {" Author ":" Http://127.0.0.1:5000/api/v1.0/users/80 "," Body ":" Sed Ante. Pellentesque ultrices mattis odio. ", body_html": null, "Comment_count": 0, "comments"
            : "http://127.0.0.1:5000/api/v1.0/posts/10/comments/", "timestamp": "Sun, Aug 2016 00:00:00 GMT", "url": "HTTP://127.0.0.1:5000/API/V1.0/POSTS/10"}, {"Author": "http://127.0.0.1:5000/api/ V1.0/USERS/58 "," Body ":" Nulla ac enim. Vestibulum ante ipsum primis in faucibus orc i luctus et ultrices posuere cubilia; Donec Pharetra, Magna Vestibulum Ali Quet ultrices, erat tortor sollicitudin mi, sit amet lobortis sapien sapien mi. " , "body_html": null, "Comment_count": 0, "comments": "http://127.0.0.1:5000/api/v1.0/p osts/11/comments/"," timestamp ":" Wed, Aug 2016 00:00:00 GMT "," url ":" Http://127.0.0.1:5000/apI/v1.0/posts/11 "}, {" Author ":" Http://127.0.0.1:5000/api/v1.0/users/4 "," Body ": "Vestibulum rutrum rutrum neque. Donec vitae nisi. Fusce con gue, diam ID ornare imperdiet, sapien urna pretium nisl, ut volutpat sapien arcu sed augue.
            Integer Aliquet, Massa ID lobortis convallis, tortor risus, Dapibus a ugue, vel accumsan, tellus eu nisi. ", "body_html": null, "Comment_count": 0, "comments": "Http://127.0.0.1:5000/api/v1.0/posts/12/comme nts/"," timestamp ":" Sat, Aug 2016 00:00:00 GMT "," url ":" http://127.0.0.1:5000/api/v1.0/posts/ "}, {" Author ":" Http://127.0.0.1:5000/api/v1.0/users/43 "," Body ":" Praesent bl Andit Lacinia erat. Lorem ipsum dolor sit amet, consectetuer adipiscing. Donec posuere metus vitae ipsum.  In Hac habitasse Platea dictumst. "," body_html ": null," Comment_count ": 0," comments ": "Http://127.0.0.1:5000/api/v1.0/posts/13/comments/"," timestamp ":" Wed, Aug 2016 00:00:00 GMT "," URL ":" HTTP://127.0.0.1:5000/API/V1.0/POSTS/13 "}, {" Author ":" Http://127.0.0.1:5000/api/v1.0 /USERS/63 "," Body ":" Nam tristique tortor EU pede. Etiam Justo. Vestibulum ante ipsum primis in Faucibus orci luctus et ultrices posuere cubilia; Nulla da pibus dolor vel est. Nulla tempus. Pellentesque ultrices mattis odio. ", body_html": null, "Comment_count": 0, "comments"
            : "http://127.0.0.1:5000/api/v1.0/posts/14/comments/", "timestamp": "Sat, Aug 2016 00:00:00 GMT", "url": "HTTP://127.0.0.1:5000/API/V1.0/POSTS/14"}, {"Author": "http://127.0.0.1:5000/api/ V1.0/USERS/83 "," Body ":" Vivamus metus arcu, adipiscing molestie, hendrerit at, Vulp utate Vitae, nisl. Integer pede Justo, Lacinia eget, tincidunt eget, Tempus vel, pedE. vestibulum ante ipsum primis in Faucibus orci luctus et ultrices posuere cubilia curae; Mauris viverra diam vitae quam. "," body_html ": null," Comment_count ": 0," comments ":"
            http://127.0.0.1:5000/api/v1.0/posts/15/comments/"," timestamp ":" Sat, Aug 2016 00:00:00 GMT ", "url": "Http://127.0.0.1:5000/api/v1.0/posts/15"}, {"Author": "Http://127.0.0.1:5000/api/v1." 0/users/82 "," Body ":" Quisque erat eros, Viverra eget, congue eget, semper rutrum, nulla. "," the body 
            _html ": null," Comment_count ": 0," comments ":" http://127.0.0.1:5000/api/v1.0/posts/16/comments/",
        "Timestamp": "Tue, Aug 2016 00:00:00 GMT", "url": "HTTP://127.0.0.1:5000/API/V1.0/POSTS/16"
            }, {"Author": "Http://127.0.0.1:5000/api/v1.0/users/48", "Body": "Nulla ac enim.", "body_html": null, "Comment_couNT ": 0," comments ":" http://127.0.0.1:5000/api/v1.0/posts/17/comments/"," timestamp ":" Fri, Aug 2016 00:00:00 GMT ", url": "Http://127.0.0.1:5000/api/v1.0/posts/17"}, {"Author ":" HTTP://127.0.0.1:5000/API/V1.0/USERS/13 "," Body ":" Nunc nisl. CRAs non velit nec nisi vulputate nonummy. Nulla neque libero, convallis eget, Eleifend luctus, Ultricies, EU, nibh. CRAs mi pede, malesuada in, Imperdiet et, Commodo vulputate, Justo. ", body_html": null, "comment  _count ": 0," comments ":" http://127.0.0.1:5000/api/v1.0/posts/18/comments/"," timestamp ":" Sun, 28 Aug 2016 00:00:00 GMT ", url": "Http://127.0.0.1:5000/api/v1.0/posts/18"}, {"Au
            Thor ":" http://127.0.0.1:5000/api/v1.0/users/75 "," Body ":" Nulla nisl. "," body_html ": null, "Comment_count": 0, "comments": "Http://127.0.0.1:5000/api/v1.0/posts/19/comments/"," timestamp ":" Thu, SEP 2016 00:00:00 GMT "," url ":" http://127.0.0
            .1:5000/api/v1.0/posts/19 "}, {" Author ":" Http://127.0.0.1:5000/api/v1.0/users/46 ", "Body": "Donec semper sapien a libero." Vestibulum ante ipsum primis in Faucibus orci luctus et ultrices posuere cubilia; Mauris Viverra diam v itae quam. ", body_html": null, "Comment_count": 0, "comments":
            "http://127.0.0.1:5000/api/v1.0/posts/20/comments/", "timestamp": "Sun, Aug 2016 00:00:00 GMT", ' URL ': ' HTTP://127.0.0.1:5000/API/V1.0/POSTS/20 '}], ' prev ': null}

Anonymous users

(venv) C:\Users\Geek lee\flasky>http--json--auth:get http://127.0.0.1:5000/a pi/v1.0/posts/http/1.0-OK content-lengt h:8456 Content-type:application/json Date:mon, Sep 2016 14:17:26 GMT server:werkzeug/0.10.4 Python/3.4.3 {"Co Unt ":", "Next": "http://127.0.0.1:5000/api/v1.0/posts/?page=2", "posts": [{"Author": "Htt P://127.0.0.1:5000/API/V1.0/USERS/4 "," Body ":" SSS "," body_html ": null," Comment_count ": 0," comments ":" http://127.0.0.1:5000/api/v1.0/posts/1/comments/"," timestamp ":" Fri, Sep 20 02:32:52 GMT ", url": "Http://127.0.0.1:5000/api/v1.0/posts/1"}, {"Author": " HTTP://127.0.0.1:5000/API/V1.0/USERS/4 "," Body ":" Fsdfsdfs "," body_html ": null," comm Ent_count ": 0," comments ":" http://127.0.0.1:5000/api/v1.0/posts/2/comments/"," timestamp ":" Fri, Sep 2016 02:32:GMT ", url": "Http://127.0.0.1:5000/api/v1.0/posts/2"}, {"Author": "Http://12 7.0.0.1:5000/API/V1.0/USERS/4 "," Body ":" Sdfsdfsfs "," body_html ": null," Comment_count ": 0," comments ":" http://127.0.0.1:5000/api/v1.0/posts/3/comments/"," timestamp ":" Fri, Sep 20 02:32:59 GMT ", url": "Http://127.0.0.1:5000/api/v1.0/posts/3"}, {"Author": " HTTP://127.0.0.1:5000/API/V1.0/USERS/4 "," Body ":" FSDFSFSAFSFA "," body_html ": null," C Omment_count ": 0," comments ":" http://127.0.0.1:5000/api/v1.0/posts/4/comments/"," timestamp ":" Fr
            I, SEP 2016 02:33:03 GMT ", url": "Http://127.0.0.1:5000/api/v1.0/posts/4"}, { "Author": "Http://127.0.0.1:5000/api/v1.0/users/4", "body": "Why."
  "," body_html ": null," Comment_count ": 0,          "Comments": "http://127.0.0.1:5000/api/v1.0/posts/5/comments/", "timestamp": "Fri, SEP 2016 02:51 : + GMT ", url": "HTTP://127.0.0.1:5000/API/V1.0/POSTS/5"}, {"Author": "Http://1 27.0.0.1:5000/api/v1.0/users/7 "," Body ":" Etiam vel augue. "," body_html ": null," comme Nt_count ": 0," comments ":" http://127.0.0.1:5000/api/v1.0/posts/6/comments/"," timestamp ":" Wed, 2 4 Aug 2016 00:00:00 GMT ", url": "HTTP://127.0.0.1:5000/API/V1.0/POSTS/6"}, {"Au Thor ":" Http://127.0.0.1:5000/api/v1.0/users/39 "," Body ":" CRAs in Purus EU magna vulputate. Suspendisse potent i. In Quis Justo. Morbi vestibulum, velit ID pretium iaculis, diam erat fermentu m justo, nec condimentum neque sapien, Placerat. Etiam vel augue. "," body_html ": null," Comment_count ": 0," comments ":" http://127.0.0. " 1:5000/api/v1.0/posts/7/comments/"," timestamp ":" Fri, Aug 2016 00:00:00 GMT "," url ":" http://127.
            0.0.1:5000/api/v1.0/posts/7 "}, {" Author ":" HTTP://127.0.0.1:5000/API/V1.0/USERS/52 ", "Body": "Integer ac neque." Vestibulum rutrum rutrum Neque.
             Aenean au ctor gravida sem. Quisque ut erat. ",

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.