Last active
December 31, 2015 05:59
-
-
Save alexsavio/7944439 to your computer and use it in GitHub Desktop.
IPython notebooks on how to use Virtualenv and Virtualenvwrapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "metadata": { | |
| "name": "" | |
| }, | |
| "nbformat": 3, | |
| "nbformat_minor": 0, | |
| "worksheets": [ | |
| { | |
| "cells": [ | |
| { | |
| "cell_type": "markdown", | |
| "metadata": {}, | |
| "source": [ | |
| "#Using curl as HTTP client" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "metadata": {}, | |
| "source": [ | |
| " To improbe text output of curl:\n", | |
| " \n", | |
| " echo '-w \"\\n\"' >> ~/.curlrc" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "metadata": {}, | |
| "source": [ | |
| "#### Setting up server variables\n", | |
| "\n", | |
| " server=http://127.0.0.1:8080/api\n", | |
| " \n", | |
| " req_hjson=\"Content-Type:application/json\"\n", | |
| " req_hxml=\"Content-Type:application/xml\"\n", | |
| " \n", | |
| " resp_hjson=\"Accept:application/json\"\n", | |
| " resp_hxml=\"Accept:application/xml\"\n", | |
| " \n", | |
| " header='json'\n", | |
| " #header='xml'\n", | |
| " if [ $header == 'json' ]\n", | |
| " then\n", | |
| " H=${req_hjson}\n", | |
| " elif [ $header == 'xml' ]\n", | |
| " then\n", | |
| " H=${req_hxml}\n", | |
| " fi" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "metadata": {}, | |
| "source": [ | |
| "#### First connection tests\n", | |
| "\n", | |
| " curl -H ${H} -X GET ${server}/user\n", | |
| " \n", | |
| " curl -H ${req_hjson} -X POST -d '{\"name\": \"alexsavio\", \"age\":31}' -i ${server}/user\n", | |
| " \n", | |
| " curl -H ${H} -i ${server}/user\n", | |
| " \n", | |
| " curl -i ${server}/user/529e0fcab93af65cf5c7f919" | |
| ] | |
| }, | |
| { | |
| "cell_type": "markdown", | |
| "metadata": {}, | |
| "source": [ | |
| "#### Patching a document\n", | |
| "\n", | |
| " curl -H ${req_hjson} -i ${server}/user/52a5d47db93af6517de9b336\n", | |
| " \n", | |
| "Copy the etag\n", | |
| "\n", | |
| " etag_match=\"If-Match:3d4b3aa11bbb0652775ee92895c3de89da1f03bc\"\n", | |
| " \n", | |
| " curl -H ${req_hjson} -H ${etag_match} -X PATCH -d '{\"age\":31}' -i ${server}/user/52a5d47db93af6517de9b336" | |
| ] | |
| } | |
| ], | |
| "metadata": {} | |
| } | |
| ] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment